我是靠谱客的博主 复杂大门,这篇文章主要介绍【springboot】发送邮箱不能够连接到主机,现在分享给大家,希望可以做个参考。

最近在导出邮箱的时候发现服务器报错,但是在本地就没事,提示错误

 nested exception is com.sun.mail.util.MailConnectException:
Couldn't connect to host, port: smtp.qq.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.qq.com, 25; timeout -1;

发现是连接不到主机,百度问题发现是因为阿里云处于安全考虑,TCP 25 端口默认被封禁。
可以向阿里云申请解封,也可以改为ssl加密465端口发送

我这里是将端口改成了465
在yml文件中修改mail配置

spring:
mail:
host: smtp.qq.com
userName: xxxx@qq.com
passWord: 认证指令
default-encoding: UTF-8
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
port: 465
protocol: smtps

我们加上一下两个就可以了

 port: 465
protocol: smtps

最后

以上就是复杂大门最近收集整理的关于【springboot】发送邮箱不能够连接到主机的全部内容,更多相关【springboot】发送邮箱不能够连接到主机内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部