Mandrill嵌入的图像无法正确解释 [英] Mandrill embed image cannot get interpreted properly

查看:76
本文介绍了Mandrill嵌入的图像无法正确解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Node.js中使用Mandrill向客户发送电子邮件,并希望将图像嵌入到电子邮件附带的html内容中.我从中找到了一些解决方案https://mandrill.zendesk.com/hc/en-us/articles/205582457-Tips-for-using-images-in-Mandrill-emails ,并决定使用第4个,其中包括图像内联在html中.代码如下:

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);
})

htmlContent 中相应的html代码为

And the corresponding html code in htmlContent is

<img src="cid:logo">

但是,当我在Mandrill出站活动中检查了已发送的电子邮件时,查看内容"无法正确显示图像.然后我查看了html源,发现图像代码仍然是

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?

谢谢.

推荐答案

最后,我发现在检查Mandrill出站活动中的已发送电子邮件时,它只是不起作用,但在您的实际电子邮件收件箱中仍然可以正常工作.因此,这意味着您在进行测试时将永远看不到嵌入的图像,必须将其与生产api密钥一起发送,并在真实的电子邮件收件箱中查看结果.

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. :)

这篇关于Mandrill嵌入的图像无法正确解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆