Got bad greeting from SMTP host: smtp.163.com, port: 465, response: [EOF]


  在Spring Boot项目中,使用org.springframework.mail.javamail.JavaMailSender发送邮件抛异常,异常信息: 

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

  问题分析:设置邮件协议的时候,配置如下:

spring.mail.protocol=smtp

  #设置ssl端口

  spring.mail.port=465

注意,是smtp,结尾没有字母s。另外,在不设置该属性的时候,系统默认使用SMTP协议。

  解决方案:修改配置文件,使用邮件传输协议SMTPS,使得传输协议与端口465相匹配:

spring.mail.protocol=smtps

  结论:重启服务,经验证问题搞定。其实,网上很多人写的博客都把配置信息写错了,我就是抄错了,这里记下来,亡羊补牢。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM