# Email notifications incorrectly assign attachments into multipart/alternative

**URL:** https://meta.discourse.org/t/email-notifications-incorrectly-assign-attachments-into-multipart-alternative/141844
**Category:** Bug
**Created:** [February 17, 2020, 10:06pm UTC](https://meta.discourse.org/t/email-notifications-incorrectly-assign-attachments-into-multipart-alternative/141844 "2020-02-17T22:06:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![djr013](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@djr013](https://meta.discourse.org/u/djr013)
#### Post date: [February 17, 2020, 10:06pm UTC](https://meta.discourse.org/t/email-notifications-incorrectly-assign-attachments-into-multipart-alternative/141844/1 "2020-02-17T22:06:47Z")

</div>

When sending email notifications along with attachments, the resulting multipart MIME structure is malformed. Attachments are included as an “alternative” part, rather than as a “mixed” part. As a result, some email clients, like Thunderbird, do not display these attachments because they’re interpreted as merely an alternative format of the email’s content, as with text vs HTML.

[Following quote is from [an essentially identical bug report against Mailer](https://github.com/hanami/mailer/issues/78) which also relies on the Mail module.]

> what i’m expecting the email to be structured like:
> 
> ```plaintext
> multipart/mixed
> multipart/alternative
> text/plain
> text/html
> application/pdf (i.e. in case of pdf attachment)
> 
> ```
> 
> what i’m receiving:
> 
> ```plaintext
> multipart/alternative
> text/plain
> text/html
> application/pdf (i.e. in case of pdf attachment)
> 
> ```
> 
> the practical effect:  
> thunderbird renders the right text body, depending on user preference (txt or html), but does not show the attachment as an attached file (it is however in the email source code as a bas63-encoded block) ios mail shows an empty email body, and only the pdf attachment as a file, since it is the last entry, and apparently the mail client then only renders this.

There are a handful of possibly-related bug reports against the [Mail module](https://github.com/mikel/mail) Discourse relies on. Some of these reports are closed with an unstated implication that feeding the parts in a particular way solves the issue. I’m not sure which is the case here, but several of those reports are linked from the report I quoted and linked above.

---

<div class="post-metadata">

### Author: ![daniel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniel/32/172786_2.png) [@daniel](https://meta.discourse.org/u/daniel)
#### Post date: [March 17, 2020, 9:33am UTC](https://meta.discourse.org/t/email-notifications-incorrectly-assign-attachments-into-multipart-alternative/141844/5 "2020-03-17T09:33:30Z")

</div>

Thanks for reporting this and for providing a clear description of the problem!

This should now be fixed as of [FIX: Notification emails with attachments are incorrectly structured · discourse/discourse@59578df · GitHub](https://github.com/discourse/discourse/commit/59578dfc5b9c7c445170b55614419362ba08a44b).

---

<div class="post-metadata">

### Author: ![daniel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniel/32/172786_2.png) [@daniel](https://meta.discourse.org/u/daniel)
#### Post date: [March 21, 2020, 6:00pm UTC](https://meta.discourse.org/t/email-notifications-incorrectly-assign-attachments-into-multipart-alternative/141844/6 "2020-03-21T18:00:08Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
