Oct. 1, 2013, 8:49 a.m.

iPhone not displaying multipart/mixed emails

I have recently had to write an application that sends out emails with attachments. This is not a hard thing to do, as is evident from the multipart/mixed RFC. My initial attempts worked perfectly when receiving the email via Apple's Mail.app. However, on the iPhone and iPad these emails rendered with the body text:

This message cannot be displayed because of the way it is formatted. Ask the sender to send it again using a different format or email program. multipart/mixed

No body text and no attachments showed up. Naturally I tried to search for the issue to see if other people experienced the same problem. Some people did. However either there were no solutions to the questions or the responses were your typical non developer users who has no better recommendation than to "reboot the phone".

I decided to send myself an email with an attachment using Mail.app and compare the raw source with what my program created. They looked identical. Here is the basic structure of a multipart/mixed message:

Content-Type: multipart/mixed; boundary="XXX-mixed-3538f37d942f9f90112c636a0dc200ec"
From: someone@somewhere.com
Subject: Some subject.  

Content-Transfer-Encoding: 7bit
Content-Type: text/plain;

Hi internet,

This is a simple mail body text.


Content-Disposition: inline;
Content-Type: application/pdf;
Content-Transfer-Encoding: base64



This is correct - this matches with the guidelines of the RFC. Eventually I spotted the problem. It was not the formatting of the mail body, it had to do with the headers. This was shown implicitly in the RFC, but never elaborated on as a requirement.

Adding this to the header resolved the issue and the mail shows up perfectly on iPhone and iPad:

Mime-Version: 1.0