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


springboot用qq郵箱的smtp服務發送郵件時報錯Got bad greeting from SMTP host: smtp.qq.com, port: 465, response: [EOF]

解決方案

如果使用端口為465,將protocol的smtp改為smtps
如果使用端口為587,則可以使用smtp。
均為SSL連接端口,因為qq不支持非SSL端口。
以下是配置文件,主要在於protocal(視端口而定)和開啟SSL(必須)

spring:
  mail:
    # 郵件服務器地址
    host: smtp.qq.com
    # 協議 默認就是smtp
    protocol: smtp
    # 編碼格式 默認就是utf-8
    default-encoding: utf-8
    # 發件人郵箱
    username: yourmail@qq.com
    # 授權碼 不是郵箱密碼
    password: xxxxxxxxxxxxxxxx

    # smtp的指定端口 使用465要將protocol改為smtps
    port: 587
    # 設置開啟ssl
    properties:
      mail:
        stmp:
          ssl:
            enable: true


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM