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

posted @ 2021-10-26 15:05  .Blank  阅读(1262)  评论(0编辑  收藏  举报