springboot Got bad greeting from SMTP host: smtp.qq.com, port: 465

148 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

新切的服务器,从腾讯云换到了阿里云,然后邀请朋友注册这个平台,结果朋友说邮件收不到,我突然想起来,25端口没有申请解封.

下午是一顿申请解封25端口,阿里云可没腾讯云那么便利,人家是一直审核不通过,给人工打电话,售后的同学回复说产品规则,不能人工干预,我擦...

好吧,那就切到465端口吧!本以为改改配置就能通过,实际情况是这样子滴

Mail server connection failed; nested exception is javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.qq.com, port: 465, response: [EOF]. Failed messages: javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.qq.com, port: 465, response: [EOF]

原因呢是因为没有改protocal类型,465对应的是smtps,springboot配置要改成这个样子:

spring.mail.host=smtp.qq.com
spring.mail.username=账号@qq.com
spring.mail.password=你的授权码
spring.mail.protocol=smtps
spring.mail.port=465
spring.mail.default-encoding=utf-8
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true

改完之后再次测试注册功能,ok了