Skip to content
Open
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
4 changes: 4 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ custom_tpl = """
[email]
enabled = false
server = "smtp.gmail.com"
# 可选:发件人邮箱地址。
# 部分服务商(如 SendGrid)SMTP 登录账号(username)为 API Key 而非邮箱地址,
# 此时需在此填写真实发件邮箱;留空则默认使用 username 作为发件地址。
Comment on lines +120 to +122
#from = "user@email.com"
username = "user@email.com"
password = "***"
to = "user1@email.com;user2@email.com"
Expand Down
4 changes: 3 additions & 1 deletion server/src/notifier/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct Config {
pub server: String,
pub username: String,
pub password: String,
pub from: Option<String>,
pub to: String,
pub subject: String,
pub title: String,
Expand Down Expand Up @@ -48,9 +49,10 @@ impl crate::notifier::Notifier for Email {
}

fn send_notify(&self, html_content: String) -> Result<()> {
let from_addr = self.config.from.as_deref().unwrap_or(&self.config.username);
let mut builder = Message::builder()
.subject(self.config.subject.clone())
.from(format!("ServerStatus <{}>", self.config.username).parse().unwrap());
.from(format!("ServerStatus <{from_addr}>").parse().unwrap());
Comment thread
zdz marked this conversation as resolved.

let mailboxes: Mailboxes = self.config.to.parse().expect("Invalid email addresses");
for mailbox in mailboxes.iter() {
Expand Down
Loading