Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mandrill embed image cannot get interpreted properly

Tags:

mandrill

I'm using Mandrill in Nodejs to send emails to customers, and want to embed an image in my html content attached to the emails. I found some solutions from https://mandrill.zendesk.com/hc/en-us/articles/205582457-Tips-for-using-images-in-Mandrill-emails and decided to use the 4th one, which includes the image inline in the html. The code is as below:

var message = {
  html: htmlContent,
  subject: "Subject",
  ...
  images = [{
    "type": logo.logoType, // which is "image/jpeg"
    "name": "logo",
    "content": content // the content is valid when using in <img src="data:image/jpeg;base64,content"> directly
  }]
};
mandrillClient.messages.send({
  message: message
}, function() {
  callback(null);
}, function(err) {
  callback(err);
})

And the corresponding html code in htmlContent is

<img src="cid:logo">

However, when I checked with the sent email in Mandrill Outbound Activity, "View Content" doesn't show the image correctly. And I looked at the html source, found the image code was still as

<img src="cid:logo">

The plain text didn't get replaced by image data.

How can I get it work properly? Any ideas?

Thanks in advance.

like image 908
Junlynn Avatar asked Dec 27 '25 23:12

Junlynn


1 Answers

Finally I found it just didn't work when checking the sent email in Mandrill Outbound Activity, but it works fine in your actual email inbox. So it means you will never see the embedded image when do testing, you must send it with production api key and see the results in a real email inbox.

Just FYI. Hope no one will waste any time on this like I did. :)

like image 99
Junlynn Avatar answered Dec 30 '25 22:12

Junlynn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!