且构网

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

无法在Linux中使用JavaMail API发送电子邮件

更新时间:2022-02-08 21:29:58

如果Java/JavaMail无法检测到您当前的主机名,则可能发生这种情况.使用属性mail.smtp.localhost显式指定EHLO/HELO的主机名.

This can happen if Java/JavaMail cannot detect your current hostname. Use property mail.smtp.localhost to explicitly specify the hostname for EHLO/HELO.

来自 https://javamail .java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html :

mail.smtp.localhost String
SMTP HELO或EHLO命令中使用的本地主机名.默认为InetAddress.getLocalHost().getHostName().如果您的JDK和名称服务配置正确,通常不需要设置.

mail.smtp.localhost String
Local host name used in the SMTP HELO or EHLO command. Defaults to InetAddress.getLocalHost().getHostName(). Should not normally need to be set if your JDK and your name service are configured properly.

作为更长期的解决方案,您可能想要找出InetAddress.getLocalHost().getHostName()为什么(显然)没有返回主机名的原因.

As a more long term solution, you might want to find out why InetAddress.getLocalHost().getHostName() is (apparently) not returning a hostname.