'Could not convert socket to TLS Spring Mail
I am getting the errors: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate). Failed messages: javax.mail.MessagingException: Could not convert socket to TLS; Email sender service class:
@Service
public class EmailSenderService {
@Autowired
private JavaMailSender mailSender;
public void sendEmail(String toEmail,
String subject,
String body){
SimpleMailMessage message=new SimpleMailMessage();
message.setFrom("[email protected]");
message.setTo(toEmail);
message.setText(body);
message.setSubject(subject);
mailSender.send(message);
System.out.println("Mail Sent Successfully...");
}
Mail Controller:
@Autowired
EmailSenderService emailSenderService;
@RequestMapping("/mail")
public String sendMail(HttpSession session, Model model){
emailSenderService.sendEmail("[email protected]","Test","This is the body of the test email");
session.setAttribute("mailMessage", "Check your email");
return "redirect:/dashboard";
}
Solution 1:[1]
I experienced the same problem today. My antivirus was at fault. After temporarily disabling Avast the mail sender worked as expected.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kirsten Ali |