0
点赞
收藏
分享

微信扫一扫

JAVA邮件发送:Sending the email to the following server failed

爱做梦的夏夏 2022-02-16 阅读 56

HtmlEmail使用QQ企业邮箱发送问题总结

按HtmlEmail上的参数信息进行本地邮件发送测试通过后,将服务部署在云服务器上测试邮件发送出现第一个报错:

Sending the email to the following server failed : smtp.exmail.qq.com:25

通过在云服务器上直接ping smtp.exmail.qq.com这个域名发现服务器上外网没有连通,打开外网权限后,仍然存在上述报错。
浏览文档尝试将SmtpPort切换成465端口:

HtmlEmail.setSmtpPort(465);

仍然报错:

Sending the email to the following server failed : smtp.exmail.qq.com:465
Could not connect SMTP host:smtp.exmail.qq.com, port 465, response: -1

发现切换成465端口时,需要将SSLOnConnect设置为true

HtmlEmail.setSSLOnConnect(true);

修改后报错信息变更为:

Invalid address

最后将SmtpPort切换成587:

HtmlEmail.setSmtpPort(587);

终于不报错了,记录一下,方便之后复查。

举报

相关推荐

0 条评论