A
A
Anton Voskoboev2021-04-12 22:50:38
Java
Anton Voskoboev, 2021-04-12 22:50:38

Why email sending error with Java 16?

The application has sending email via gmail. On Java 11 - 15 everything works without problems, when switching to Java 16 the following error in the log:

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;
  nested exception is:
  javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate); message exceptions (1) are:
Failed message 1: 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)


mail sender configuration:

@Bean
  public JavaMailSender getJavaMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost("smtp.gmail.com");
    mailSender.setPort(587);
    mailSender.setDefaultEncoding("UTF-8");
    mailSender.setUsername("[email protected]");
    mailSender.setPassword("password");

    Properties props = mailSender.getJavaMailProperties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");

    return mailSender;
  }


Who faced?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Voskoboev, 2021-05-17
@Besyzr

Switching to another version of the protocol helped:
props.put("mail.smtp.ssl.protocols", "TLSv1.2");

O
Orkhan, 2021-04-12
Hasanly @azerphoenix

Failed messages: javax.mail.MessagingException: Could not convert socket to TLS;

Add to props
props.put("mail.smtp.ssl.trust", "smtp.gmail.com");

https://stackoverflow.com/questions/16115453/javam...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question