gpt4 book ai didi

spring - 收到来自 SMTP 主机 : smtp. yandex.ru、端口 : 465, 的错误问候响应:[EOF]] 与根本原因 Yandex

转载 作者:行者123 更新时间:2023-12-04 14:35:28 26 4
gpt4 key购买 nike

我使用带有下一个 Maven 依赖项的全新 Spring Boot 项目

 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
方法的实现
 @Autowired
JavaMailSender emailSender;

@GetMapping("/send")
public String send() {
SimpleMailMessage message = new SimpleMailMessage();
message.setFrom("some-name@domain.com");
message.setTo("toReceiver@gmail.com");
message.setSubject(null);
message.setText("Hello World");
emailSender.send(message);
return "success send email " + now();
}
应用程序.yml
host: smtp.yandex.ru
username: some-name@domain.io
password: password
port: 465
并接收下一个异常
2020-08-03 23:02:35.102 ERROR 21615 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : 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 javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.yandex.com, port: 465, response: [EOF]. 
Failed messages: javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.yandex.com, port: 465, response: [EOF]; message exceptions (1) are: Failed message 1: javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.yandex.com, port: 465, response: [EOF]] with root cause但相同的代码与 Mailtrap 完美配合服务
根据这个 link我使用了不安全的 25 端口
之后我收到了下一个异常
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.yandex.ru, 25; timeout -1;
587端口=
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: [EOF];
我猜 SSL 有问题
类似 issue

最佳答案

使用端口:465(SMTP 协议(protocol)),您可以尝试通过属性启用 ssl:
"mail.smtp.ssl.enable": 真

mail.smtp.ssl.enable: If set to true, use SSL to connect and use the SSL port by default. Defaults to false for the "smtp" protocol and true for the "smtps" protocol.
使用 spring boot,向 application.yml 添加属性:
 mail:
...
properties:
"mail.smtp.ssl.enable": true
引用:
Outgoing mail
mail server address — smtp.yandex.com
connection security — SSL
port — 465
SMTP 协议(protocol)提供程序支持以下属性:
https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html

关于spring - 收到来自 SMTP 主机 : smtp. yandex.ru、端口 : 465, 的错误问候响应:[EOF]] 与根本原因 Yandex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63236701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com