Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue with feedback emails with text and html body, and an attachment. #2694

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Apr 4, 2025

Email::Stuffer incorrectly adds an attachment together with the text and html body parts all at the same level with content type multipart/mixed. Structurally this is as follows:

[
    (content type with multipart/mixed)
    text body,
    html body,
    attachment
]

As a result, when an email has a text body, an html body, and an attachment, both the text and html are shown in most email clients.

The text and html body should be parts of a separate part that has content type 'multipart/alternative'. So the email has two parts, and the first part has two parts in that which are the text and html body. The second part is the attachment. The following shows how it should be structurally:

[
    (content type multipart/mixed)
    [
       (content type multipart/alternative)
        text body,
        html body
    ],
    attachment
]

To fix this, before adding an attachment the text and html body are moved into a separate part with content type multipart/alternative.

This is something that I noticed when working on issue #2690. I use Thunderbird, and was confused when I got the old text email with the attachment. Scrolling down I discovered that the html body was there as well.

@drgrice1 drgrice1 force-pushed the text-html-attachment-issue branch from f693450 to cc8fbd0 Compare April 4, 2025 01:13
@pstaabp
Copy link
Member

pstaabp commented Apr 8, 2025

I don't have a way to test this right now, but looks fine.

…achment.

Email::Stuffer incorrectly adds an attachment together with the text and
html body parts all at the same level with content type multipart/mixed.
Structurally this is as follows:

[
    (content type multipart/mixed)
    text body,
    html body,
    attachment
]

As a result, when an email has a text body, an html body, and an
attachment, both the text and html are shown in most email clients.

The text and html body should be parts of a separate part that has
content type 'multipart/alternative'.  So the email has two parts, and
the first part has two parts in that which are the text and html body.
The second part is the attachment. The following shows how it should be
structurally:

[
    (content type multipart/mixed)
    [
       (content type multipart/alternative)
        text body,
        html body
    ],
    attachment
]

To fix this, before adding an attachment the text and html body are
moved into a separate part with content type multipart/alternative.
@drgrice1 drgrice1 force-pushed the text-html-attachment-issue branch from cc8fbd0 to 7b38ea7 Compare April 8, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants