且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java邮件通过TLS

更新时间:2023-12-04 23:25:28

您需要使用 smtps 协议而不是 smtp

You need to use the smtps protocol instead of smtp

props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.starttls.enable","true");
props.put("mail.smtps.auth", "true");
props.put("mail.smtps.host", "mail.xxxx.com");
props.put("mail.smtps.port", "587");

您还可以尝试为rfc822设置特定的协议,这有助于某些时间

You can also try to set the protocol specificly for rfc822, this helps some times

props.put("mail.transport.protocol.rfc822", "smtps");