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

您所在的位置:网站首页 为什么qq邮箱发邮件发不出去 解决springboot项目部署到阿里云服务器邮箱无法发送邮件而本地可以问题(亲测有用)

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

2024-07-09 08:47| 来源: 网络整理| 查看: 265

解决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: 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; nested exception is: java.net.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: smtp.qq.com, 25; timeout -1; nested exception is: java.net.ConnectException: Connection timed out (Connection timed out)] with root cause

前篇踩雷: 试了网友的这个方法!试了没有用!(也可能自己项目用不了吧!!也不能说别人的没啥用哈哈哈哈) 在这里插入图片描述 后来: 翻了别的csdn,试了可以用!

在application.properties添加以下代码 # SSL Config spring.mail.port=465 spring.mail.protocol=smtp spring.mail.default-encoding=UTF-8 spring.mail.properties.mail.smtp.ssl.enable=true spring.mail.properties.mail.smtp.socketFactory.port=465 spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory

即为: 在这里插入图片描述

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

成功啦!!!!!!!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3