diff --git a/sample/config.sample.sh b/sample/config.sample.sh index 734f4ae5..4627fdb5 100644 --- a/sample/config.sample.sh +++ b/sample/config.sample.sh @@ -201,6 +201,8 @@ export SMTP_EMAIL="" export SMTP_PASSWORD="" ## smtp_name 填写 SMTP 收发件人姓名,可随意填写 export SMTP_NAME="" +## smtp_email_to 填写 SMTP 收件邮箱,可选 +export SMTP_EMAIL_TO="" ## 17. PushMe ## 官方说明文档:https://push.i-i.me/ diff --git a/sample/notify.py b/sample/notify.py index 8dd885ca..e7eb031f 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -108,6 +108,7 @@ push_config = { 'SMTP_SERVER': '', # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465 'SMTP_SSL': 'false', # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false 'SMTP_EMAIL': '', # SMTP 收发件邮箱,通知将会由自己发给自己 + 'SMTP_EMAIL_TO': '', # SMTP 收件邮箱,填了则会发送到这个邮箱 'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定 'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写 @@ -690,6 +691,7 @@ def smtp(title: str, content: str) -> None: return print("SMTP 邮件 服务启动") + email_to = push_config.get("SMTP_EMAIL_TO") or push_config.get("SMTP_EMAIL") message = MIMEText(content, "plain", "utf-8") message["From"] = formataddr( ( @@ -700,7 +702,7 @@ def smtp(title: str, content: str) -> None: message["To"] = formataddr( ( Header(push_config.get("SMTP_NAME"), "utf-8").encode(), - push_config.get("SMTP_EMAIL"), + email_to, ) ) message["Subject"] = Header(title, "utf-8") @@ -716,7 +718,7 @@ def smtp(title: str, content: str) -> None: ) smtp_server.sendmail( push_config.get("SMTP_EMAIL"), - push_config.get("SMTP_EMAIL"), + email_to, message.as_bytes(), ) smtp_server.close()