java sends email using ssl protocol through javamail
First of all, javamail needs to be the latest javax.mail-1.6.2.jar. Below I will post the key writing methods that need to be used for your reference.
props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.host", smtpHost);
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.connectiontimeout", connectiontimeout);
props.setProperty("mail.smtp.timeout", timeout);
props.setProperty("mail.smtp.socketFactory.fallback","false");
props.setProperty("mail.smtp.ssl.protocols", "TLSv1.2");
props.put("mail.smtp.ssl.enable", "true");
props.setProperty("mail.smtp.socketFactory.port", String.valueOf(port));
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.smtp.port", String.valueOf(port));
With this setting, you can send emails normally, and you will find isssl true through the logs.