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

Inline attachments are not included in attachments field #15

Open
joeyAghion opened this issue Jan 16, 2015 · 15 comments
Open

Inline attachments are not included in attachments field #15

joeyAghion opened this issue Jan 16, 2015 · 15 comments

Comments

@joeyAghion
Copy link

Inline attachments are provided by the Mandrill webhook's images field and are not included in the attachments field. As such, they're not available in the Griddler::Email's attachments property.

I think they should be folded into the attachments property. Thoughts?

@wingrunr21
Copy link
Owner

I tentatively agree with that. I haven't used inline attachments with Mandrill. Do they keep a reference to the attachment in the email body? Would folding them into attachments remove that reference?

@joeyAghion
Copy link
Author

Yes, the email body can include something like <img src="cid:foobar">. The images field might then look like:

{"foobar"=>
  {"name"=>"foobar",
   "type"=>"image/jpeg",
   "content"=>
    "/9j/4AAQSkZJRgA...eiojyQf/9k="}}

Because the content-ID also appears as the name property, I think clients would still have all the necessary information if these were folded into attachments.

@wingrunr21
Copy link
Owner

Sounds good to me.

@wingrunr21
Copy link
Owner

@joeyAghion are you planning on submitting a PR for this?

@joeyAghion
Copy link
Author

Hey @wingrunr21 I was but am still experimenting. It turned out that this wasn't quite enough to support our use case. All the data would be available in the revised attachments field, but it wouldn't be clear which attachments were inline or weren't. If someone else is interested in the half-fix I laid out here, I'm happy to PR it.

Another note, in case someone else pursue this: it turns out the Mandrill docs are misleading. The images field is supposed to include a base64 boolean just like attachments, but in practice it doesn't. Meanwhile, the contents are base64-encoded.

@rdetert
Copy link

rdetert commented May 13, 2015

This is biting me too. Going to see if I have better luck with Sendgrid.

@mfkp
Copy link

mfkp commented Aug 9, 2015

So this explains why some emails are missing attachments. iPhone users generally paste images into the emails instead of doing a classic attachment, and when they do that, my email processor is failing because it doesn't think that there's anything attached. Anybody actually get this working, or are we all just switching to sendgrid?

@wingrunr21
Copy link
Owner

I'd love a PR if someone sends one along. If the iPhone use case can consistently reproduce this then I can also try and find some time to work on a fix.

@mfkp
Copy link

mfkp commented Aug 9, 2015

Hmm, I actually just had a friend test with Mail.app on iPhone and it actually worked fine in the attachments and pasting the image, but it seems like it's more of a problem when pasting an image inside the Gmail app. Might just be a Gmail issue in fact, so ignore what I said.

@wingrunr21
Copy link
Owner

haha ok. Well then, still looking for a PR or repeatable use case.

@mfkp
Copy link

mfkp commented Aug 25, 2015

FYI - https://github.com/kat3kasper/griddler-mandrill

Just came back to this and found a way to reproduce. I use Airmail for my desktop email app. Attaching files normally comes through as attachments, but if you drag an image from finder into the email, it gets added as an inline attachment, which then shows up in the images hash instead of attachments.

The fork above seems to make it work, but it might not be suitable for all cases.

@wingrunr21
Copy link
Owner

Ok, great. I'll try and take a look at this then.

@holden
Copy link

holden commented Dec 16, 2015

+1 Need it too!

@MicTech MicTech mentioned this issue Jan 7, 2016
@wingrunr21
Copy link
Owner

#27 has been merged. Images will be extracted and added into the attachments field of Griddler.

I've got a couple more enhancements coming (specifically around determining whether an attachment was inline or not).

@TanookiMario
Copy link

TanookiMario commented Mar 9, 2018

Hi! I just came across this issue. I am trying to send inline attachments with griddler/mandrill for a Rails app. Whenever it gets processed the attachments have incorrect names. I inspected the raw_text of the email and noticed this:

<img src="cid:1620c85e6d0d0b594a91" alt="Yzma_(2)_(2)_(1)_(3)_(2)_(1).jpg" class="" style="max-width: 100%;">

it seems like the ActionDispatch::Http::UploadedFile created by rails is using the cid from the img tag as the filename, instead of the alt, which is the actual file name. Is there a reason the actual name of the uploaded file is not being used for the cid? How is the cid being made?

Any info would help! thanks!

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