feat: add encryption setting for email notifier (#4686)

#### What type of PR is this?
/kind improvement
/area core
/milestone 2.10.x

#### What this PR does / why we need it:
为邮件通知发件设置增加加密方式配置

#### Which issue(s) this PR fixes:
Fixes #4674

#### Does this PR introduce a user-facing change?
```release-note
为邮件通知发件设置增加加密方式配置
```
pull/4680/head
guqing 2023-10-08 17:44:14 +08:00 committed by GitHub
parent df22b4b5ea
commit 815f6b82c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

View File

@ -107,7 +107,19 @@ public class EmailNotifier implements ReactiveNotifier {
Properties props = javaMailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "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 @@ public class EmailNotifier implements ReactiveNotifier {
private String password;
private String host;
private Integer port;
private String encryption;
/**
* Gets email display name.

View File

@ -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