From 59b8c7a6b8089d282eda06c3c3bf3700643b58cf Mon Sep 17 00:00:00 2001 From: Marcos Lenharo Date: Wed, 7 May 2025 16:56:07 -0300 Subject: [PATCH] Add email related content support (RFC2387). MIME multipart contents can access other parts when using "multipart/related" Content-Type. This allows, for example, the HTML body to embed attached image files accepted by email clients and email web clients following RFC 2387. Additionally it is necessary to add the Content-ID header to the attachment part so the html body can link it. This commit inserts the Content-ID to each attachment with filename as the tag value, allowing the HTML body to reference it using: Tested with: - Outlook - Thunderbird - Windows and Linux - IOS Native email app - GMAIL - Web Interface - GMAIL - Android and IOS APP --- apprise/plugins/email/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apprise/plugins/email/base.py b/apprise/plugins/email/base.py index ce89cb3d..bf118112 100644 --- a/apprise/plugins/email/base.py +++ b/apprise/plugins/email/base.py @@ -927,7 +927,7 @@ class NotifyEmail(NotifyBase): base = MIMEText(body, 'plain', 'utf-8') if attach: - mixed = MIMEMultipart("mixed") + mixed = MIMEMultipart("related") mixed.attach(base) # Now store our attachments for no, attachment in enumerate(attach, start=1): @@ -959,6 +959,10 @@ class NotifyEmail(NotifyBase): Header(filename, 'utf-8')), ) mixed.attach(app) + app.add_header( + 'Content-ID', + '<{}>'.format(Header(filename, 'utf-8')), + ) base = mixed if pgp: