mirror of
https://github.com/Cp0204/quark-auto-save.git
synced 2026-01-20 20:59:37 +08:00
✨ SMTP 邮件通知支持收发分离、支持多收件人
Some checks are pending
Docker Publish / build-and-push (push) Waiting to run
Some checks are pending
Docker Publish / build-and-push (push) Waiting to run
(cherry picked from commit be7a7edff2989015a44a49e8fd3dce4ba1be16a7)
This commit is contained in:
parent
8bc876646d
commit
138bfde587
19
notify.py
19
notify.py
@ -101,9 +101,11 @@ push_config = {
|
||||
|
||||
'SMTP_SERVER': '', # SMTP 发送邮件服务器,形如 smtp.exmail.qq.com:465
|
||||
'SMTP_SSL': 'false', # SMTP 发送邮件服务器是否使用 SSL,填写 true 或 false
|
||||
'SMTP_EMAIL': '', # SMTP 收发件邮箱,通知将会由自己发给自己
|
||||
'SMTP_EMAIL': '', # SMTP 发件邮箱
|
||||
'SMTP_PASSWORD': '', # SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定
|
||||
'SMTP_NAME': '', # SMTP 收发件人姓名,可随意填写
|
||||
'SMTP_NAME': '', # SMTP 发件人姓名,可随意填写
|
||||
'SMTP_EMAIL_TO': '', # SMTP 收件邮箱,可选,缺省时将自己发给自己,多个收件邮箱逗号间隔
|
||||
'SMTP_NAME_TO': '', # SMTP 收件人姓名,可选,可随意填写,多个收件人逗号间隔,顺序与 SMTP_EMAIL_TO 保持一致
|
||||
|
||||
'PUSHME_KEY': '', # PushMe 的 PUSHME_KEY
|
||||
'PUSHME_URL': '', # PushMe 的 PUSHME_URL
|
||||
@ -679,12 +681,23 @@ def smtp(title: str, content: str) -> None:
|
||||
push_config.get("SMTP_EMAIL"),
|
||||
)
|
||||
)
|
||||
if not push_config.get("SMTP_EMAIL_TO"):
|
||||
smtp_email_to = push_config.get("SMTP_EMAIL")
|
||||
message["To"] = formataddr(
|
||||
(
|
||||
Header(push_config.get("SMTP_NAME"), "utf-8").encode(),
|
||||
push_config.get("SMTP_EMAIL"),
|
||||
)
|
||||
)
|
||||
else:
|
||||
smtp_email_to = push_config.get("SMTP_EMAIL_TO").split(",")
|
||||
smtp_name_to = push_config.get("SMTP_NAME_TO","").split(",")
|
||||
message["To"] = ",".join([formataddr(
|
||||
(
|
||||
Header(smtp_name_to[i] if len(smtp_name_to) > i else "", "utf-8").encode(),
|
||||
email_to,
|
||||
)
|
||||
) for i, email_to in enumerate(smtp_email_to)])
|
||||
message["Subject"] = Header(title, "utf-8")
|
||||
|
||||
try:
|
||||
@ -698,7 +711,7 @@ def smtp(title: str, content: str) -> None:
|
||||
)
|
||||
smtp_server.sendmail(
|
||||
push_config.get("SMTP_EMAIL"),
|
||||
push_config.get("SMTP_EMAIL"),
|
||||
smtp_email_to,
|
||||
message.as_bytes(),
|
||||
)
|
||||
smtp_server.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user