Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multipart emails with attachments don't display properly on iOS devices #590

Closed
landlord11 opened this issue Jul 26, 2013 · 6 comments
Closed

Comments

@landlord11
Copy link

When composing a mail with a multipart/alternative body the attachments are lumped into the same multipart/alternative part as the message body alternatives. iOS devices will display only one of the parts, typically the last attachment (i.e., only one attachment and no body displays).

The solution is that the multipart/alternative part should only contain the text_part and html_part, and that part should be added to an enclosing multipart/mixed that also holds the attachments. This can be constructed using the existing module doing something along these lines:

mail=Mail.new do |mail|
  @bodypart = Mail::Part.new do
    text_part do
      body "this is my message"
    end
    html_part do
      content_type 'text/html; charset=UTF-8'
      body %Q[<html><body>this is my message in HTML</body></html>]
    end
  end
  add_part @bodypart
end
# add attachments

A message built this way will work with iOS. Can the library be altered to make this unnecessary (i.e., so using text_part and html_part automatically structure the message this way?) Thanks.

@dclausen
Copy link

I'm also experiencing this issue using Mail.app on a OSX 10.8.4 after upgrading from mail-2.3.3 to mail-2.5.3

chrismdp pushed a commit to chrismdp/dotfiles that referenced this issue Oct 7, 2013
The old perl file was inpenetrable: this is a bit slower but does the
job. Note the need for `bodypart` (cf. mikel/mail#590)
@chrismdp
Copy link

chrismdp commented Oct 7, 2013

I get the same problem: the workaround is shown in the commit above.

@steve500002
Copy link

I have the same problem but am unable to get the workaround above to solve the problem. I just cannot seem to add attachments in a way that iOS can handle. Has anyone have a simple example they can share?

@chrismdp
Copy link

@steve500002 I wrote a bit more about it here:

http://chrismdp.com/2013/10/using-markdown-to-send-html-email-via-mutt/

Does that help?

@steve500002
Copy link

Thanks Chris - that helped me understand what I needed to do to get iOS to display the emails correctly.

For others - the key is that (as Chris says in link above) is to have the attachments outside the multipart/alternative block.

I have a gist (https://gist.github.com/steve500002/bfc4b027d93c0c04f126) with my code that builds an email to send so you can see the steps I took to get this to work.

@bicz
Copy link

bicz commented Jun 9, 2014

Thanks. This workaround works perfectly.

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

No branches or pull requests

6 participants