When sending mail using Jakarta email throwing below exception 


> jakarta.mail.MessagingException: Could not convert socket to TLS; 
> nested exception is: 	java.net.SocketException: A connection attempt
> failed because the connected party did not properly respond after a
> period of time, or established connection failed because connected
> host has failed to respond 	at
> com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2140) 	at
> com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:734)
> 	at jakarta.mail.Service.connect(Service.java:364) 	at
> jakarta.mail.Service.connect(Service.java:222) 	at
> jakarta.mail.Service.connect(Service.java:171) 	at
> jakarta.mail.Transport.send0(Transport.java:230) 	at
> jakarta.mail.Transport.send(Transport.java:100) 	at
> test.GmailSSLTest.main(GmailSSLTest.java:44)



Tried below code in local to send mail using jakarta email using port 587, but its throwing above mentioned exception

```
package test;

import jakarta.mail.*;
import jakarta.mail.internet.*;
import java.util.Properties;

public class GmailTest {
 public static void main(String[] args) throws Exception {
 Properties props = new Properties();
 props.put("mail.smtp.host", "smtp.gmail.com");
 props.put("mail.smtp.port", "587");
 props.put("mail.smtp.auth", "true");
 props.put("mail.smtp.starttls.enable", "true");
 props.put("mail.smtp.starttls.required", "true");
 props.put("mail.smtp.ssl.enable", "false");
 props.put("mail.smtp.ssl.protocols", "TLSv1.2");
 props.put("mail.debug", "true");

 Session session = Session.getInstance(props, new Authenticator() {
 @Override
 protected PasswordAuthentication getPasswordAuthentication() {
 return new PasswordAuthentication(
 "*****@gmail.com", 
 "******" 
 );
 }
 });

 Message msg = new MimeMessage(session);
 msg.setFrom(new InternetAddress("*****@[email protected]"));
 msg.setRecipients(Message.RecipientType.TO,
 InternetAddress.parse("*****@[email protected]"));
 msg.setSubject("Test mail");
 msg.setText("Hello from Jakarta Mail via Gmail 587 STARTTLS!");
 Transport.send(msg);
 System.out.println("Message sent!");
 }
}
```

> Using below dependencies jakarta.activation-2.0.1.jar
> jakarta.mail-2.0.2