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

Comments

Projects
None yet
6 participants
@landlord11

landlord11 commented Jul 26, 2013

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

This comment has been minimized.

Show comment
Hide comment
@dclausen

dclausen Sep 23, 2013

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

dclausen commented Sep 23, 2013

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 added a commit to chrismdp/config_files that referenced this issue Oct 7, 2013

Ruby script for mangling mail to allow HTML part as markdown
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

This comment has been minimized.

Show comment
Hide comment
@chrismdp

chrismdp Oct 7, 2013

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

chrismdp commented Oct 7, 2013

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

@steve500002

This comment has been minimized.

Show comment
Hide comment
@steve500002

steve500002 Jan 31, 2014

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?

steve500002 commented Jan 31, 2014

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

This comment has been minimized.

Show comment
Hide comment
@chrismdp

chrismdp commented Jan 31, 2014

@steve500002

This comment has been minimized.

Show comment
Hide comment
@steve500002

steve500002 Feb 1, 2014

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.

steve500002 commented Feb 1, 2014

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

This comment has been minimized.

Show comment
Hide comment
@bicz

bicz Jun 9, 2014

Thanks. This workaround works perfectly.

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