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

Add configuration option for email sender address apart from SMTP username #5351

Merged
merged 4 commits into from
Mar 24, 2024
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 @@ -88,7 +88,7 @@ private static MimeMessagePreparator getMimeMessagePreparator(String toEmail,
return mimeMessage -> {
MimeMessageHelper helper =
new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8.name());
helper.setFrom(emailSenderConfig.getUsername(), emailSenderConfig.getDisplayName());
helper.setFrom(emailSenderConfig.getSender(), emailSenderConfig.getDisplayName());

helper.setSubject(payload.getTitle());
helper.setText(payload.getRawBody(), payload.getHtmlBody());
Expand Down Expand Up @@ -166,6 +166,7 @@ static class EmailSenderConfig {
private String host;
private Integer port;
private String encryption;
private String sender;

/**
* Gets email display name.
Expand All @@ -175,5 +176,14 @@ static class EmailSenderConfig {
public String getDisplayName() {
return StringUtils.defaultIfBlank(displayName, username);
}

/**
* Gets email sender address.
*
* @return sender if not blank, otherwise username.
*/
public String getSender() {
return StringUtils.defaultIfBlank(sender, username);
}
}
}
5 changes: 5 additions & 0 deletions application/src/main/resources/extensions/notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ spec:
label: "用户名"
name: username
validation: required
- $formkit: text
if: "$enable"
label: "发信地址"
name: "sender"
help: "如果用户名为实际发信地址,可忽略"
- $formkit: password
if: "$enable"
label: "密码"
Expand Down