mail.smtp.ssl.enable
JavaMail APIを使用するときに、プロパティをtrueに設定するいくつかのサイトを読みました。私は次のようないくつかのコードを持っています:
props.put("mail.smtp.host", "exchangemail1.example.com");
props.put("mail.from", "myemail@example.com");
props.put("mail.smtp.starttls.enable", "true");
// I tried this by itself and also together with ssl.enable)
props.put("mail.smtp.ssl.enable", "true");
Session session = Session.getInstance(props, null);
MimeMessage msg = new MimeMessage(session);
msg.setFrom();
msg.setRecipients(Message.RecipientType.TO, "me.at@example.com");
// also tried @gmail.com
msg.setSubject("JavaMail ssl test");
msg.setSentDate(new Date());
msg.setText("Hello, world!\n");
props.put("mail.smtp.auth", "false");
Transport trnsport;
trnsport = session.getTransport("smtp");
trnsport.connect();
msg.saveChanges();
trnsport.sendMessage(msg, msg.getAllRecipients());
trnsport.close();
これによりメールが送信されますが、次のようになります。
- トラフィックキャプチャを実行すると、暗号化されていないことがわかります
- debug(
props.put("mail.debug", "true")
)を使用すると、「isSSLfalse」が表示されます
props.put("mail.smtp.auth","true")
(上記で+ユーザー/パスワードを追加してみました...)
私が間違っていることについて何か考えはありますか?