rjbs / Email-Stuffer

for sending stuff through email
7 stars 22 forks source link

Dual HTML & plain text email content with attachment fails. #60

Open neilpgl opened 2 years ago

neilpgl commented 2 years ago

I used email stuffer to compose an email with both HTML and plain text content. It works great.

I can also use it to attach a file to an HTML content body. It works fine.

But when I do both, my email client, both with Thunderbird and mail.com, show the plain text content AND the HTML content together, with the HTML displayed as text so tags like "< p >" appear in the email body. The attachment still works fine.

This very much appears to be a bug within email stuffer.

Attachment is a pdf document.

Thunderbird version: 78.14.0

Email Stuffer version: 0.018

Perl: (v5.28.1)

Thanks.

Frank071 commented 2 years ago

This is due to the way how Email::Stuffer combines the attachments. If it finds (at least) two parts, then it creates a 'multipart/alternative' email with all parts. That is not correct, as the attachments are no alternatives to the body. The correct way is to create an Email::MIME object of type 'multipart/alternate' with two parts and 'multipart/alternative' as type. That object should itself be part of an Email::MIME object of type 'multipart/mixed', of which the attachments are parts as well. If you want to use inline images in the HTML body it gets even more complicatd, because those need to be in a combined 'multipart/related' container together with the html body.

I made some alterations to Email::Stuffer to accommodate for this, but that was on the metacpan version of the module and that differs from this Github version. Perhaps later I will create a fork and supply patches.