Я использую новый проект весенней загрузки со следующей зависимостью Maven
<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();
}
application.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 service
Согласно этой ссылка Я использовал незащищенный порт 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
Подобный выпуск