Issue with inline images #25

Closed
bigal488 opened this Issue Mar 23, 2012 · 4 comments

Comments

Projects
None yet
2 participants

Its great that emailjs supports inline images:
#16
..but I'm seeing some strange behaviour: The inline images appear twice in my mail reader (Os X Mail app) Once inline and then again as an attachment.

Tried a different reader (Google Mail) but there the image doesn't appear inline and just shows up as an attachment.

I'm wondering if this is because the attached inline image should be inside the boundary for the HTML content of the message?

A bit of juggling around with the boundaries shows that another level of boundary nesting with Content-Type: multipart/related needs to be introduced to get inline images to display properly. The nested level contains the encoded html and the image.

something like this:

Content-Type: multipart/mixed; boundary="masterboundary"

--masterboundary
Content-Type: multipart/alternative; boundary="partboundary"

--partboundary
Content-Type:text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Plain text here

--partboundary
Content-Type: multipart/related; boundary="subpartboundary"

--subpartboundary
content-type: text/html; charset=utf-8
content-transfer-encoding: base64
content-disposition: inline

base64-encoded-html-here

--subpartboundary
content-type: image/png
content-transfer-encoding: base64
content-disposition: inline; filename=renamed.png
content-id:

base64-encoded-inline-image-here

--subpartboundary--

--partboundary--

--masterboundary--

Owner

eleith commented Mar 25, 2012

thanks @bigal488 for looking into this.

i'll push a fix through in the next week or so.

Owner

eleith commented Mar 27, 2012

@bigal488 i have pushed a branch called 'fix-inline-images'

basically, i added support for 'multipart/related'. can you please test it to see if this fixes this issue for you on the mail clients you are testing on?

you can see in test/test.js how to attach related attachments...

Nice!
..in fact really nice!! It works perfectly and I think having an array of related attachments inside the message.attach object is a great idea.
Many thanks for getting this resolved so quickly.

bigal488 closed this Mar 27, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment