public void sendMailWithPx() {
try {
Process p = Runtime.getRuntime().exec(new String[]{
getPathSendMail(),
"-t"
});
String base64File = encodeFileToBase64Binary("/Users/jacye/Downloads/test.pdf");//base64 file
try (OutputStreamWriter osw = new OutputStreamWriter(p.getOutputStream(), "UTF8")) {
osw.write("Content-Type: application/pdf\n");
osw.write("From: [email protected]\n");
osw.write("To: [email protected]\n");
osw.write("Subject: Test send mmail\n");
osw.write("CC: [email protected]\n");
osw.write("BCC: [email protected]\n");
osw.write("Content-Disposition: attachment; filename=test.pdf");
osw.write("\n");
osw.write("Content-Transfer-Encoding: base64");
osw.write("\n");
osw.write(base64File);
osw.write("this is body");
}
p.waitFor();
} catch (IOException | InterruptedException e) {
log.error(null, e);
}
}
private String getPathSendMail() throws IOException {
Properties prop = new Properties();
try (InputStream input = getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)) {
prop.load(input);
return prop.getProperty("sendmail.path");
}
}
添付ファイルと本文をメールで送信しますが、受信本文はありません。SendmailはJavaコードを使用し、本文を追加できません
本文と添付ファイルをメールで送信するにはどうすればよいですか?
なぜあなたはJavaMailのを使用することはありませんでしょうか?私の顧客のために –
セキュリティ..私は私を助けることができます。 – Jaycey
これはコマンドライン自体から機能しますか? –