fix:邮件设置开启TLS时,发送邮件失败

This commit is contained in:
wenyann 2021-07-16 17:47:17 +08:00 committed by 刘瑞斌
parent 888bf1d3f8
commit 63a38213c9
1 changed files with 3 additions and 1 deletions

View File

@ -27,11 +27,12 @@ public class MailService {
javaMailSender.setDefaultEncoding("UTF-8");
javaMailSender.setProtocol("smtp");
props.put("mail.smtp.auth", "true");
String smtpHost = "";
for (SystemParameter p : paramList) {
switch (p.getParamKey()) {
case "smtp.host":
javaMailSender.setHost(p.getParamValue());
smtpHost = p.getParamValue();
break;
case "smtp.port":
javaMailSender.setPort(Integer.parseInt(p.getParamValue()));
@ -52,6 +53,7 @@ public class MailService {
String result = BooleanUtils.toString(BooleanUtils.toBoolean(p.getParamValue()), "true", "false");
props.put("mail.smtp.starttls.enable", result);
props.put("mail.smtp.starttls.required", result);
props.put("mail.smtp.ssl.trust", smtpHost);
break;
/* case "smtp.anon":
boolean isAnon = BooleanUtils.toBoolean(p.getParamValue());