简体   繁体   中英

Getting javax.net.ssl.SSLHandshakeException: No appropriate protocol exception while sending mail through smtp

I am trying to send the mail from my spring boot application. The following are the smtp configurations I have added in application.yml

spring:
  mail:
    host: smtp.gmail.com
    port: 587
    username: ${username}
    password: ${app-password}
    properties:
      mail:
        transport:
          protocol: smtp
        smtp:
          auth: true
          starttls:
            enable: true

But when I am trying to send the mail, I am getting the following exception

Mail server connection failed; nested exception is
    javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
    javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate).
Failed messages: javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
    javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)"

Please help me with this. I have searched many blogs, my configurations seems to be fine. Let me know If I need to change or add something.

Thanks in advance!

This looks tls algorithm is part of your disabledAlgorithms list in jdk which is running in your system.

While link shared by Marc Stroebel might help you but if you want to set this programatically as well, then you can use below in your spring startup:

@SpringBootApplication
public class App {
    public static void main(String[] args) {
      java.security.Security.setProperty("jdk.tls.disabledAlgorithms", "");
      ..
      ..
    }
}

This will allow all algorithms while app execution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM