zbateson / mail-mime-parser

An email parser written in PHP
https://mail-mime-parser.org/
BSD 2-Clause "Simplified" License
458 stars 58 forks source link

Gmail inline image #90

Closed lessthanweb closed 5 years ago

lessthanweb commented 5 years ago

Hi,

So I'm piping emails and forwarding them. All works apart from Gmail inline images.

Sending an email to pipe from let's say Roundcube with an inline image, I can forward this email and attach the inline image. All good and great.

Sending an email from Gmail to pipe however does not work with AddEmbeddedImage function.

getAllAttachmentParts function sees the inline image and I can attach it to the email as an attachment but not as it should be, as an inline image.

While Roundcube uses "cid" for inline images, Gmail uses this format: [image: filename.jpg]

Am I missing something obvious here?

zbateson commented 5 years ago

Hi @lessthanweb --

Hard to say based on the description alone. From the sounds of it, the parser is able to read the parser and attach it... I'm guessing since you're parsing and re-attaching there's some manipulation of the email involved.

As far as the inline images go and how a client displays them, it's not entirely parsing related. I'm guessing when you reattach the image could there be a header that isn't included? I'm not familiar with how gmail inlines images. Also the format [image: filename.jpg] is that in the html portion or plain-text portion? I've seen some plain text that would do something similar.

lessthanweb commented 5 years ago

Oh, you are right.

Content-Type: text/plain; charset="UTF-8"

[image: mc2.jpg]

Content-Type: text/html; charset="UTF-8"

<div dir="ltr"><div><img src="cid:ii_jwix7w5k0" alt="mc2.jpg" width="542" height="353"><br></div></div>

Strange that it switched to plain-text.. I think we are good here, thanks for the help!