Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apprise/plugins/email/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ def prepare_emails(subject, body, from_addr, to,
base = MIMEText(body, 'plain', 'utf-8')

if attach:
mixed = MIMEMultipart("mixed")
mixed = MIMEMultipart("related")
Copy link
Owner

@caronc caronc May 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great to support having the attachments show inline, but this isn't ideal for say a non-graphical attachment. Say a video, pdf, etc to which "mixed" is still a better option.

I think there are 2 levels needed here... one, only switch to inline if an option on the mailto:// is provided ... perhaps a ?inline=yes option. and ONLY if that is set, an additional check needs to be made right here in the code you changed. One that just looks at attach.mimetype... something like:

if attach.mimetype.startswith('image/'):
   mixed = MIMEMultipart("mixed")

Here is an example of where this kind of check exists elsewhere.

Forcing everything to be inline though (per RFC2387) is not ideal. Thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your suggestion of creating a new switch.

One thing that I'm not sure is whether the new switch should follow item 4 of RFC2387 and change the Content-Disposition tag from "attachment" to "inline" to help non-RFC2387 compliant clients to handle it.

Regarding your suggestion on checking the attach.mimetype: The "mixed" type is at the top of email body, not on the attachment level, so it would be necessary to list all attachments and check if at least one of them is a "image/" and then change the multipart type.

What do you think about these two points?

mixed.attach(base)
# Now store our attachments
for no, attachment in enumerate(attach, start=1):
Expand Down Expand Up @@ -959,6 +959,10 @@ def prepare_emails(subject, body, from_addr, to,
Header(filename, 'utf-8')),
)
mixed.attach(app)
app.add_header(
'Content-ID',
'<{}>'.format(Header(filename, 'utf-8')),
)
base = mixed

if pgp:
Expand Down