Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Fix bug: emails with attachments not showing correctly #17

Closed
wants to merge 1 commit into from
Closed

Fix bug: emails with attachments not showing correctly #17

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 12, 2011

No description provided.

@jeremy
Copy link
Member

jeremy commented Mar 30, 2012

Could you explain?

@alphaone
Copy link

alphaone commented May 2, 2012

I have the same problem. If a mail has inline attachments (for images used in the mail) the mail_view will display the binary data of the images

@moll
Copy link

moll commented Jul 23, 2012

Just stumbled upon this problem myself, too. Seems like it's not merged to the latest mail_view 1.0.3 gem, either.

@ziazek
Copy link

ziazek commented Aug 27, 2012

Had the same problem. This fix works for me.

@jonleighton
Copy link
Contributor

Also encountered this and the fix seems to work. I'll try to add a test for it tomorrow.

@jonleighton
Copy link
Contributor

I think this problem is related to Action Mailer incorrectly generating the MIME layout - see rails/rails#2686.

This causes the mail.parts method to return e.g. an image/png part (for the attachment) and a multipart/alternative part containing the text and html parts. But neither of those two match text/html, so the #find returns nil, and we instead get mail.parts.first which is an image/png.

I think this will not be a problem when rails/rails#2686 is resolved, but in the mean time it would be good to have a workaround in mail_view to handle this.

@jonleighton
Copy link
Contributor

Actually, ignore that. The problem is simply that Action Mailer uses a container multipart/alternative part, like this:

multipart/related
  multipart/alternative
    text/plain
    text/html
  attachment

Since the mail.parts method doesn't recurse, we only see the multipart/alternative and the attachment. Hence we need to use all_parts instead.

@jeremy
Copy link
Member

jeremy commented Sep 14, 2012

Fixed by #28

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants