• 发送邮件时报:Could not convert socket to TLS错误
  • 发布于 2个月前
  • 1186 热度
    0 评论
问题
内网IT部门给了一个邮箱账号,不需要使用密码就可以在内网发送邮件,当然只能发内部企业邮件,企鹅、163之类的是不可以的。
发送邮件用的 starter 版本如下,请对号入座:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-mail</artifactId>
    <version>1.5.10.RELEASE</version>
</dependency>
邮件配置:
spring.mail.host=smtp.52itstyle.com
spring.mail.username=admin@52itstyle.com
spring.mail.password=
# 既然不需要密码,设置为 false 即可
spring.mail.properties.mail.smtp.auth=flase
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
报错:
Could not convert socket to TLS;
不能把socket解析为TLS,我们只需要把当前 smtp host 设为可信任即可。
# 这里设置信任
spring.mail.properties.mail.smtp.ssl.trust=smtp.52itstyle.com
继续报错:
535 5.7.3 Authentication unsuccessful
最终配置:
spring.mail.host=smtp.52itstyle.com
spring.mail.username=admin@52itstyle.com
# 内网发送把密码去掉就可以
#spring.mail.password=
spring.mail.properties.mail.smtp.auth=flase
spring.mail.properties.mail.smtp.ssl.trust=smtp.52itstyle.com
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true

用户评论