Answer the question
In order to leave comments, you need to log in
Why is the email sending error?
When sending a message,
it throws an error:
javax.mail.AuthenticationFailedException: 535 Error: authentication failed
@RestController
@RequiredArgsConstructor
public class SendMail {
private final JavaMailSender sender;
@RequestMapping("/test")
public String sendMail(){
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom("massage");
mailMessage.setTo("[email protected]");
mailMessage.setSubject("Здравствуйте!");
mailMessage.setText("Отправил");
sender.send(mailMessage);
return "Message send!";
}
}
spring.mail.port = 465
spring.mail.properties.mail.smtp.socketFactory.port = 465
spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socketFactory.fallback = false
spring.mail.properties.mail.smtp.tsl.enable=true
spring.mail.host=smtp.163.com
spring.mail.username=*********
spring.mail.password=******
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
Answer the question
In order to leave comments, you need to log in
Decided!
changed spring.mail.host=smtp.163.com to spring.mail.host=smtp.gmail.com
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question