Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add encryption setting for email notifier #4686

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -154,6 +166,7 @@ static class EmailSenderConfig {
private String password;
private String host;
private Integer port;
private String encryption;

/**
* Gets email display name.
Expand Down
12 changes: 12 additions & 0 deletions application/src/main/resources/extensions/notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down