Spring Boot - 无法连接到 SMTP 主机:smtp.gmail.com,端口:25,响应:421 [英] Spring Boot - Could not connect to SMTP host: smtp.gmail.com, port: 25, response: 421

查看:57
本文介绍了Spring Boot - 无法连接到 SMTP 主机:smtp.gmail.com,端口:25,响应:421的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gmail smtp 主机通过 spring boot 和 JavaMail Sender 发送邮件:

I'm using gmail smtp host t send mails with spring boot and JavaMail Sender :

我的邮件属性:

 spring.mail.host = smtp.gmail.com
 spring.mail.username = XXX@gmail.com
 spring.mail.password = XXX

 spring.mail.properties.mail.smtp.auth = true
 spring.mail.properties.mail.smtp.socketFactory.port = 465
 spring.mail.properties.mail.smtp.starttls.enable = true
 spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
 spring.mail.properties.mail.smtp.socketFactory.fallback = false

出现错误:

Failed message 1: javax.mail.MessagingException: Could not connect to SMTP host: smtp.9business.fr, port: 25, response: 421] with root cause

即使我使用的是 465 端口,为什么他指向 25 端口?

even if I'm using port 465 why is he pointing to port 25 ?

推荐答案

其实我发现是哪里出了问题,我应该用一个是我服务器的端口,另一个是gmail服务器的端口:

Actually I found what going wrong, I should use both one of them is the port of my server and the other the one of gmail server :

spring.mail.properties.mail.smtp.socketFactory.port = 25
mail.smtp.port= 465

这篇关于Spring Boot - 无法连接到 SMTP 主机:smtp.gmail.com,端口:25,响应:421的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆