项目中使用到qq邮箱进行批量发送邮件的经常会报如下的错误:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 465, response: 550 at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1960) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642) at javax.mail.Service.connect(Service.java:295) at javax.mail.Service.connect(Service.java:176)
或者这样的错误:
com.sun.mail.smtp.SMTPSendFailedException: 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726
或者:
javax.mail.MessagingException: Could not connect to SMTP host: smtp.qq.com, port: 465, response: -1
大多是因为一段时间内发送邮件太频繁,导致被qq邮箱服务器拒绝连接了,使用定时任务或者多线程同时发送多封邮件经常会遇到这个问题
可尝试以下连接的解决方案:
https://blog.csdn.net/baidu_34211956/article/details/83544631
或者等待一段时间后再发送
腾讯官方帮助文档解释如下:
https://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000722
https://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726