griddler-mandrill
griddler-mandrill copied to clipboard
Inline attachments are not included in attachments field
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?
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?
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
.
Sounds good to me.
@joeyAghion are you planning on submitting a PR for this?
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.
This is biting me too. Going to see if I have better luck with Sendgrid.
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?
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.
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.
haha ok. Well then, still looking for a PR or repeatable use case.
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.
Ok, great. I'll try and take a look at this then.
+1 Need it too!
#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).
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!