Skip to content

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

Merged
pstaabp merged 1 commit intoopenwebwork:WeBWorK-2.20from
drgrice1:text-html-attachment-issue
May 6, 2025
Merged

Fix an issue with feedback emails with text and html body, and an attachment.#2694
pstaabp merged 1 commit intoopenwebwork:WeBWorK-2.20from
drgrice1:text-html-attachment-issue

Conversation

@drgrice1
Copy link
Copy Markdown
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
Copy Markdown
Member

pstaabp commented Apr 8, 2025

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

@drgrice1 drgrice1 force-pushed the text-html-attachment-issue branch 3 times, most recently from fde7824 to 17ae6fe Compare April 15, 2025 20:40
@drgrice1 drgrice1 force-pushed the text-html-attachment-issue branch 2 times, most recently from 3d62fc2 to e792d88 Compare April 27, 2025 16:26
@drgrice1 drgrice1 changed the base branch from develop to WeBWorK-2.20 April 29, 2025 12:25
…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 e792d88 to 75c1889 Compare April 29, 2025 20:22
@pstaabp pstaabp merged commit 9a3e2d4 into openwebwork:WeBWorK-2.20 May 6, 2025
2 checks passed
@drgrice1 drgrice1 deleted the text-html-attachment-issue branch May 6, 2025 20:50
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