Fix an issue with feedback emails with text and html body, and an attachment. #2694
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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:
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.