私が継承したコード ベースは、電子メールの本文にいくつかのヘッダー情報を出力しています。これは印刷されているものです:
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
message.writeTo(System.out);
メッセージを作成した直後であれば、上記のテキストが出力されます。
このようなものを指定するプロパティファイルまたは何かがありますか?
また、メールが到着すると、送信サーバーがこれら 3 つの属性に対して適切な/異なるヘッダー情報を書き込んだように見えます。
それを取り除くためのアイデアはありますか?
また、関数全体は次のとおりです。
private String sendConfirmationEmail (String to, String from, String subject, String body, boolean CCSender) {
try
{
String smtpHost = Properties.smtp;
String fromAddress = from;
String toAddress = to;
Properties properties = System.getProperties();
properties.put("mail.smtp.host", smtpHost);
Session session = Session.getInstance(properties, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(fromAddress));
message.setRecipient(Message.RecipientType.TO,
new InternetAddress(toAddress));
message.setRecipient(Message.RecipientType.BCC,
new InternetAddress(fromAddress));
if (CCSender) {
message.setRecipient(Message.RecipientType.CC,
new InternetAddress(from));
}
message.setSubject(subject);
message.setText(body);
message.saveChanges();
Transport.send(message);
return "1:success";
}
catch(Exception e)
{
return "0:failure "+e.toString();
}
}