File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -117,6 +117,10 @@ custom_tpl = """
117117[email ]
118118enabled = false
119119server = " smtp.gmail.com"
120+ # 可选:发件人邮箱地址。
121+ # 部分服务商(如 SendGrid)SMTP 登录账号(username)为 API Key 而非邮箱地址,
122+ # 此时需在此填写真实发件邮箱;留空则默认使用 username 作为发件地址。
123+ # from = "user@email.com"
120124username = " user@email.com"
121125password = " ***"
122126to = " user1@email.com;user2@email.com"
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ pub struct Config {
2020 pub server : String ,
2121 pub username : String ,
2222 pub password : String ,
23+ pub from : Option < String > ,
2324 pub to : String ,
2425 pub subject : String ,
2526 pub title : String ,
@@ -48,9 +49,10 @@ impl crate::notifier::Notifier for Email {
4849 }
4950
5051 fn send_notify ( & self , html_content : String ) -> Result < ( ) > {
52+ let from_addr = self . config . from . as_deref ( ) . unwrap_or ( & self . config . username ) ;
5153 let mut builder = Message :: builder ( )
5254 . subject ( self . config . subject . clone ( ) )
53- . from ( format ! ( "ServerStatus <{}>" , self . config . username ) . parse ( ) . unwrap ( ) ) ;
55+ . from ( format ! ( "ServerStatus <{from_addr }>" ) . parse ( ) . unwrap ( ) ) ;
5456
5557 let mailboxes: Mailboxes = self . config . to . parse ( ) . expect ( "Invalid email addresses" ) ;
5658 for mailbox in mailboxes. iter ( ) {
You can’t perform that action at this time.
0 commit comments