diff --git a/application/src/main/java/run/halo/app/notification/EmailNotifier.java b/application/src/main/java/run/halo/app/notification/EmailNotifier.java index 1a10e1d3c6..ee596283c1 100644 --- a/application/src/main/java/run/halo/app/notification/EmailNotifier.java +++ b/application/src/main/java/run/halo/app/notification/EmailNotifier.java @@ -107,7 +107,19 @@ private static JavaMailSenderImpl createJavaMailSender(EmailSenderConfig emailSe Properties props = javaMailSender.getJavaMailProperties(); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.starttls.enable", "true"); + if ("SSL".equals(emailSenderConfig.getEncryption())) { + props.put("mail.smtp.ssl.enable", "true"); + } + + if ("TLS".equals(emailSenderConfig.getEncryption())) { + props.put("mail.smtp.starttls.enable", "true"); + } + + if ("NONE".equals(emailSenderConfig.getEncryption())) { + props.put("mail.smtp.ssl.enable", "false"); + props.put("mail.smtp.starttls.enable", "false"); + } + if (log.isDebugEnabled()) { props.put("mail.debug", "true"); } @@ -154,6 +166,7 @@ static class EmailSenderConfig { private String password; private String host; private Integer port; + private String encryption; /** * Gets email display name. diff --git a/application/src/main/resources/extensions/notification.yaml b/application/src/main/resources/extensions/notification.yaml index 70fb1389cc..b50cf5b6dd 100644 --- a/application/src/main/resources/extensions/notification.yaml +++ b/application/src/main/resources/extensions/notification.yaml @@ -47,6 +47,18 @@ spec: label: "端口号" name: port validation: required + - $formkit: select + if: "$enable" + label: "加密方式" + name: encryption + value: "SSL" + options: + - label: "SSL" + value: "SSL" + - label: "TLS" + value: "TLS" + - label: "不加密" + value: "NONE" --- apiVersion: notification.halo.run/v1alpha1 kind: ReasonType