title: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate
body: <p>I know there is several issue created about this error but nothing was helpful for me. I have method  which is sending email with attachment on gmail server and it works fine. yesterday I bought a new mac mini m1. I tried this method to send email but it's throwing this error</p>
  <pre><code> public static void sentEmail(String report){  
      BaseTest base = new BaseTest();
      
        
        String to = base.getProps().getProperty(&quot;emailTO&quot;); ;//change accordingly  
        final String user = base.getProps().getProperty(&quot;emailFROM&quot;);//change accordingly  
        final String password = base.getProps().getProperty(&quot;emailPassword&quot;);//change accordingly  
         
        //1) get the session object     
        Properties properties = System.getProperties();  
        properties.setProperty(&quot;mail.smtp.host&quot;, &quot;smtp.gmail.com&quot;);  
        properties.put(&quot;mail.smtp.auth&quot;, &quot;true&quot;); 
        properties.put(&quot;mail.smtp.port&quot;, &quot;587&quot;);  
        properties.put(&quot;mail.smtp.starttls.enable&quot;, &quot;true&quot;);
        
        
        Session session = Session.getDefaultInstance(properties,  
         new javax.mail.Authenticator() {  
         protected PasswordAuthentication getPasswordAuthentication() {  
         return new PasswordAuthentication(user,password);  
         }  
        });  
           
        //2) compose message     
        try{  
          MimeMessage message = new MimeMessage(session);  
          message.setFrom(new InternetAddress(user));  
          message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));  
          message.setSubject(&quot;From Mobile Automation Project &quot;);  
            
          //3) create MimeBodyPart object and set your message text     
          BodyPart messageBodyPart1 = new MimeBodyPart();  
          messageBodyPart1.setText(&quot;Report&quot;);  
            
          //4) create new MimeBodyPart object and set DataHandler object to this object      
          MimeBodyPart messageBodyPart2 = new MimeBodyPart();  
        
          String filename = report;//change accordingly  
          DataSource source = new FileDataSource(filename);  
          messageBodyPart2.setDataHandler(new DataHandler(source));  
          messageBodyPart2.setFileName(filename);  
           
           
          //5) create Multipart object and add MimeBodyPart objects to this object      
          Multipart multipart = new MimeMultipart();  
          multipart.addBodyPart(messageBodyPart1);  
          multipart.addBodyPart(messageBodyPart2);  
        
          //6) set the multiplart object to the message object  
          message.setContent(multipart );  
           
          //7) send message  
          Transport.send(message);  
         
         System.out.println(&quot;Report has been sent to: &quot;+ to);  
         }catch (MessagingException ex) {ex.printStackTrace();}  
  }
  </code></pre>
  <p>Exception</p>
  <pre><code>    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)
      at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1907)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:666)
      at javax.mail.Service.connect(Service.java:317)
      at javax.mail.Service.connect(Service.java:176)
      at javax.mail.Service.connect(Service.java:125)
      at javax.mail.Transport.send0(Transport.java:194)
      at javax.mail.Transport.send(Transport.java:124)
      at com.qa.utils.TestUtils.SendEmailTLS(TestUtils.java:228)
      at com.qa.BaseTest.afterSuite(BaseTest.java:153)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
      at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
      at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
      at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:351)
      at org.testng.SuiteRunner.run(SuiteRunner.java:286)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
      at org.testng.TestNG.runSuites(TestNG.java:1039)
      at org.testng.TestNG.run(TestNG.java:1007)
      at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:284)
      at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
      at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:119)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
      at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
      at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
  Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
      at sun.security.ssl.HandshakeContext.&lt;init&gt;(HandshakeContext.java:171)
      at sun.security.ssl.ClientHandshakeContext.&lt;init&gt;(ClientHandshakeContext.java:101)
      at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
      at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394)
      at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:373)
      at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:549)
      at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:486)
      at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1902)
      ... 31 more 
  </code></pre>
  <p>I changed this parameter</p>
  <pre><code>properties.setProperty(&quot;mail.smtp.host&quot;, &quot;smtp.gmail.com&quot;);
  </code></pre>
  <p>To this</p>
  <pre><code>properties.setProperty(&quot;mail.smtp.ssl.trust&quot;, &quot;smtp.gmail.com&quot;);
  </code></pre>
  <p>But then I'm getting this exception</p>
  <pre><code>javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 587;
    nested exception is:
      java.net.ConnectException: Connection refused (Connection refused)
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
      at javax.mail.Service.connect(Service.java:317)
      at javax.mail.Service.connect(Service.java:176)
      at javax.mail.Service.connect(Service.java:125)
      at javax.mail.Transport.send0(Transport.java:194)
      at javax.mail.Transport.send(Transport.java:124)
      at com.qa.utils.TestUtils.sentEmail(TestUtils.java:189)
      at com.qa.BaseTest.afterSuite(BaseTest.java:152)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
      at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
      at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
      at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:351)
      at org.testng.SuiteRunner.run(SuiteRunner.java:286)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
      at org.testng.TestNG.runSuites(TestNG.java:1039)
      at org.testng.TestNG.run(TestNG.java:1007)
      at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:284)
      at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
      at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:119)
      at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:428)
      at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
      at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:562)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:548)
  Caused by: java.net.ConnectException: Connection refused (Connection refused)
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
      at java.net.Socket.connect(Socket.java:606)
      at java.net.Socket.connect(Socket.java:555)
      at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:321)
      at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237)
      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927)
      ... 31 more
  </code></pre>