I am trying to send a mail from Unix shell through a java program. I use Apache commons exec to do this.
The command is
mutt -s "Subject of mail" email@domain.com < file.txt
And the Java code I use is
CommandLine cmdLine = CommandLine.parse("mutt");
cmdLine.addArgument("-s");
cmdLine.addArgument("Subject of mail");
cmdLine.addArgument("email@domain.com");
cmdLine.addArgument("<");
cmdLine.addArgument("file.txt");
DefaultExecutor executor = new DefaultExecutor();
int exitValue = 0;
try {
exitValue = executor.execute(cmdLine);
} catch (IOException e) {
e.printStackTrace();
}
But this code does not work. How to do input redirection using java