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