springboot mail 異常記錄(項目)

 

mail:
  host: smtp.aliyun.com
  username: 
  password: 
  port: 25
  protocol: smtp
  default-encoding: UTF-8

以上本地Windows環境測試發送郵件正常,大約在3s能收到郵件

Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.aliyun.com, 25; timeout -1;
  nested exception is:
    java.net.ConnectException: Connection timed out (Connection timed out). Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.aliyun.com, 25; timeout -1;

以上是部署到Linux服務器上,異常信息

原因:https://help.aliyun.com/knowledge_detail/56130.html

修改配置文件

mail:
  host: smtp.aliyun.com
  username: 
  password: 
  port: 465
  protocol: smtp
  default-encoding: UTF-8

Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.aliyun.com, port: 465, response: -1. Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.aliyun.com, port: 465, response: -1

以上是再次測試接口,異常信息

原因:(資料)https://yq.aliyun.com/articles/493467?spm=5176.10695662.1996646101.searchclickresult.7be65dc0PeGOHs&aly_as=pNFQe95j

mail:
  host: smtp.aliyun.com
  username: 
  password: 
  port: 465
  protocol: smtp
  default-encoding: UTF-8
  properties.mail.smtp.ssl.enable: true #加上解決這問題

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章