Springboot整合163邮箱部署项目时发送不了邮件的解决方案

部署到腾讯云服务器时项目报错

 

Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.163.com, 25; timeout -1
    at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2210)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
    at javax.mail.Service.connect(Service.java:342)
    at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:518)
    at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:437)
    ... 25 common frames omitted

 

解决方案

yml文件中加入

spring:
mail:
host: smtp.163.com
password: KWDIFGYSZICNDWHB
username: abu13141110@163.com
default-encoding: UTF-8
properties:
mail:
smtp:
socketFactory:
class: javax.net.ssl.SSLSocketFactory
auth: true
debug: true
port: 465 # 25端口被服务器禁止了,这里要使用其他端口



解释
https://cloud.tencent.com/developer/article/1484660

 
 
 
posted @ 2020-11-18 11:52  永无八哥  阅读(941)  评论(0编辑  收藏  举报