📜  java 邮件使用 tls 1.2 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:15.903000             🧑  作者: Mango

代码示例1
// add this line mail.smtp.ssl.protocols=TLSv1.2; in properties
// in your Mail Implementation class
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.ssl.protocols","TLSv1.2");

//TO be more specific


Properties prop = new Properties();
prop.setProperty("mail.smtp.auth", "true");
prop.setProperty("mail.smtp.starttls.enable", "true");
prop.setProperty("mail.smtp.ssl.protocols", "TLSv1.2"); // New Line
prop.setProperty("mail.smtp.ssl.trust", mailUri.getHost());
mailSender.setJavaMailProperties(prop);