From d43fdc304633faf4a0b964cb1ce0078a70d7ec88 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 6 Aug 2026 08:07:57 +0000
Subject: [PATCH 1/2] Initial plan
From 230dfa0632b6fadd1a064bb5ec143bc89edb3c6a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 6 Aug 2026 08:10:56 +0000
Subject: [PATCH 2/2] feat: Add plain text mode for SMTP notifications
Co-authored-by: moesnow <11678347+moesnow@users.noreply.github.com>
---
app/setting_interface.py | 1 +
assets/config/config.example.yaml | 1 +
module/notification/smtp.py | 36 +++++++++++++++++++------------
3 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/app/setting_interface.py b/app/setting_interface.py
index a7a750fad..308c6a9bf 100644
--- a/app/setting_interface.py
+++ b/app/setting_interface.py
@@ -1468,6 +1468,7 @@ def __initCard(self):
"ssl": {"title": tr("启用 SSL"), "description": tr("可选参数,是否启用 SSL"), "type": "bool"},
"starttls": {"title": tr("启用 STARTTLS"), "description": tr("可选参数,是否启用 STARTTLS"), "type": "bool"},
"ssl_unverified": {"title": tr("跳过证书验证"), "description": tr("可选参数,是否跳过 SSL 证书验证"), "type": "bool"},
+ "plain_text": {"title": tr("纯文本模式"), "description": tr("可选参数,是否以纯文本格式发送邮件(适用于 Outlook 等邮箱)"), "type": "bool"},
},
"tutorial": """
一、什么是 SMTP?
diff --git a/assets/config/config.example.yaml b/assets/config/config.example.yaml
index 7c53f8be3..685f8a484 100644
--- a/assets/config/config.example.yaml
+++ b/assets/config/config.example.yaml
@@ -556,6 +556,7 @@ notify_smtp_port: "" # SMTP 服务器端口,默认为 465。
notify_smtp_ssl: true # 是否使用 SSL 连接 SMTP 服务器。默认为 True,可设置为 False 关闭。
notify_smtp_starttls: false # 是否使用 SSL 连接 SMTP 服务器。默认为 False,可设置为 True 关闭。
notify_smtp_ssl_unverified: false # 是否使用不经验证的 SSL 连接。默认为 False,可设置为 True 关闭。除非您使用自签名邮箱,否则不推荐启用。
+notify_smtp_plain_text: false # 是否以纯文本格式发送邮件。默认为 False(发送 HTML 格式)。true 开启后将以纯文本发送,适用于 Outlook 等将 HTML 邮件作为附件处理的邮箱。
# OneBot 通知配置(QQ 机器人)
# 已测试 NapCatQQ(https://github.com/NapNeko/NapCatQQ) 和 OpenShamrock(https://github.com/whitechi73/OpenShamrock) 可用
diff --git a/module/notification/smtp.py b/module/notification/smtp.py
index d8239e41b..36bb3a98e 100644
--- a/module/notification/smtp.py
+++ b/module/notification/smtp.py
@@ -21,21 +21,29 @@ def send(self, title: str, content: str, image_io=None):
ssl = self.params.get("ssl", True)
starttls = self.params.get("starttls", False)
ssl_unverified = self.params.get("ssl_unverified", False)
+ plain_text = self.params.get("plain_text", False)
-
- msg = MIMEMultipart('related')
- body = f'{content}
'
- if image_io:
- body += '
'
- body += '
'
- msg['Subject'] = Header(title, 'utf-8')
- msg['From'] = From
- msg['To'] = To
- if image_io:
- img = MIMEImage(image_io.getvalue())
- img.add_header('Content-ID', '')
- msg.attach(img)
- msg.attach(MIMEText(body, "html", "utf-8"))
+ if plain_text:
+ if image_io:
+ self.logger.warning("SMTP 纯文本模式下不支持发送图片,图片将被忽略")
+ msg = MIMEText(content, "plain", "utf-8")
+ msg['Subject'] = Header(title, 'utf-8')
+ msg['From'] = From
+ msg['To'] = To
+ else:
+ msg = MIMEMultipart('related')
+ body = f'{content}
'
+ if image_io:
+ body += '
'
+ body += '
'
+ msg['Subject'] = Header(title, 'utf-8')
+ msg['From'] = From
+ msg['To'] = To
+ if image_io:
+ img = MIMEImage(image_io.getvalue())
+ img.add_header('Content-ID', '')
+ msg.attach(img)
+ msg.attach(MIMEText(body, "html", "utf-8"))
if starttls:
smtp = smtplib.SMTP(host, port)