700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 解决springboot项目部署到阿里云服务器邮箱无法发送邮件而本地可以问题(亲测有用)

解决springboot项目部署到阿里云服务器邮箱无法发送邮件而本地可以问题(亲测有用)

时间:2022-03-22 09:41:46

相关推荐

解决springboot项目部署到阿里云服务器邮箱无法发送邮件而本地可以问题(亲测有用)

解决springboot项目部署到服务器邮箱无法发送邮件而本地可以问题(亲测有用)

前言:由于SpringBoot项目有发送邮箱功能,但是部署到服务器上却出现无法发送问题!但是本地却可以!!大致看了一下应该是端口的问题!

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailSendException: Mail server connection failed; nested exception is com.sun.mail.util.MailConnectException: Couldn't connect to host, port: , 25; timeout -1;nested exception is:.ConnectException: Connection timed out (Connection timed out). Failed messages: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: , 25; timeout -1;nested exception is:.ConnectException: Connection timed out (Connection timed out); message exceptions (1) are:Failed message 1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: , 25; timeout -1;nested exception is:.ConnectException: Connection timed out (Connection timed out)] with root cause

前篇踩雷:试了网友的这个方法!试了没有用!(也可能自己项目用不了吧!!也不能说别人的没啥用哈哈哈哈)

后来:翻了别的csdn,试了可以用!

在application.properties添加以下代码

# SSL Configspring.mail.port=465spring.mail.protocol=smtpspring.mail.default-encoding=UTF-8spring.mail.properties.mail.smtp.ssl.enable=truespring.mail.properties.mail.smtp.socketFactory.port=465spring.mail.properties.mail.smtp.socketFactory.class=.ssl.SSLSocketFactory

即为:

参考文章:阿里云发送不了邮件,SpringBoot 使用SSL邮箱发送邮件

成功啦!!!!!!!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。