Is Content-Transfer-Encoding needed for multipart/alternative Content-Type?

content-type, email, postfix-mta, sendmail, smtp

Solution

The statements from IETF and wikipedia aren't really contradictory. `7bit`, `8bit`, or `binary` aren't really content encodings in that they don't specify any transformation of the content. They simply state that the content hasn't been encoded. In the case of `7bit` it also specifies that the content doesn't need to be encoded even if the message needs to be sent over a transport that isn't 8-bit clean.

Only the bottom-most layers of messages should have an actual `Content-Transfer-Encoding` such as `base64` or `quoted-printable`. In the message that you quote from the outer portion certainly isn't base64 encoded, so stating that it is was not only violating the standard but also incorrect. That would certainly be expected to cause problems with display of that message.

Problem

I have an app that sends e-mails and for many months, it was working fine. I recently had problems with `utf-8` encoded emails sent to iPhone `Exchange account` (i.e. not `IMAP`). All the receiver had to see was a big bunch of meaningless characters like `LS0tLS0tPV9QYXJ0XzE0N18[....]`. Comparing my email headers with Gmail, I noticed that I had an extra `Content-Transfer-Encoding` associated with the `Content-Type: multipart/alternative;`. My email would look like ``` Delivered-To: ... Received: ... ... MIME-Version: ... Content-Type: multipart/alternative; boundary="----=_boundary" Content-Transfer-Encoding: Base64 # <= the extra setting ----=_boundary Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: Base64 YmVu0Cg== ----=_boundary Content-type: text/html; charset=utf-8 Content-Transfer-Encoding: Base64 PGh0bWwgeG1sbnM6bz0iIj48aGVhZD48dGl0bGU+PC90aXRsZT48L2hlYWQ+PGJvZHk+YmVub2l0 PC9ib2R5PjwvaHRtbD4NCjx9IjAiIC8+Cg== ----=_boundary ``` If I remove the extra setting, my email is received and display properly. My questions: - Is the `Encoding` setting basically needed with `Content-Type: multipart/alternative;`, even for specific cases ? - Is it safe to remove it and just keep using my app as I used to ? Edit I found on `IETF`: Encoding considerations: Multipart content-types cannot have encodings. But I also found on `Wikipedia`: The content-transfer-encoding of a multipart type must always be "7bit", "8bit" or "binary" to avoid the complications that would be posed by multiple levels of decoding. Isn't it contradictory ?

Original source