@@ -107,7 +107,8 @@ def print(text, *args, **kw):
107107
108108 'SMTP_SERVER' : '' , # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
109109 'SMTP_SSL' : 'false' , # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
110- 'SMTP_EMAIL' : '' , # SMTP 收发件邮箱,通知将会由自己发给自己
110+ 'SMTP_EMAIL' : '' , # SMTP 发件邮箱
111+ 'SMTP_EMAIL_TO' : '' , # SMTP 收件邮箱,多个分号分隔,默认发给发件邮箱
111112 'SMTP_PASSWORD' : '' , # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
112113 'SMTP_NAME' : '' , # SMTP 收发件人姓名,可随意填写
113114
@@ -694,19 +695,18 @@ def smtp(title: str, content: str) -> None:
694695 return
695696 print ("SMTP 邮件 服务启动" )
696697
698+ email_to = push_config .get ("SMTP_EMAIL_TO" ) or push_config .get ("SMTP_EMAIL" )
699+ email_to_list = [
700+ item .strip () for item in re .split (r"[;;]" , email_to ) if item .strip ()
701+ ]
697702 message = MIMEText (content , "plain" , "utf-8" )
698703 message ["From" ] = formataddr (
699704 (
700705 Header (push_config .get ("SMTP_NAME" ), "utf-8" ).encode (),
701706 push_config .get ("SMTP_EMAIL" ),
702707 )
703708 )
704- message ["To" ] = formataddr (
705- (
706- Header (push_config .get ("SMTP_NAME" ), "utf-8" ).encode (),
707- push_config .get ("SMTP_EMAIL" ),
708- )
709- )
709+ message ["To" ] = "," .join (email_to_list )
710710 message ["Subject" ] = Header (title , "utf-8" )
711711
712712 try :
@@ -720,7 +720,7 @@ def smtp(title: str, content: str) -> None:
720720 )
721721 smtp_server .sendmail (
722722 push_config .get ("SMTP_EMAIL" ),
723- push_config . get ( "SMTP_EMAIL" ) ,
723+ email_to_list ,
724724 message .as_bytes (),
725725 )
726726 smtp_server .close ()
0 commit comments