使用 meteorjs 发送电子邮件时,base64 内联图像显示不正确
When sending an email with meteorjs, the base64 inline image is not displayed correctly
现状:
(客户端)模板:
<template name="feedback">
<h1>The Image</h1>
<img src="{{image}}" alt=""/>
</template>
(客户端)调用邮件功能:
var dataContext={
image: canvas.toDataURL('image/png')
};
var html=Blaze.toHTMLWithData(Template.feedback, dataContext);
Meteor.call('feedback', html);
(服务器端):
Email.send({
to: 'xxx',
from: 'xxx',
subject: 'xxx',
html: html
});
预期结果:一封带有嵌入图像的精美电子邮件。
实际结果: 我收到邮件部分 html,部分 'raw' 文本。我不知道为什么。
这是我在原始电子邮件中看到的部分内容:
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<h1>The Image</h1>
=20=20=20=20<img =
src=3D"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAALKCAYAAADTWUxrAA
有什么想法吗?
Gmail 以及许多其他客户端不允许您在 img 标记中使用 base64 作为源。不过有一些方法可以解决这个问题:
第一个也是最简单的可能是将图像保留在您的服务器上并将 url 放入图像源标记中。这具有能够处理一些跟踪的额外好处(需要一些额外的开发)。
第二种方法是使用第三方邮件系统,将图像和 HTML 发送给他们,并以这种方式进行设置。出于多种原因,这可能是好的,但它并不能真正回答您的问题。
最后,您可以像现在这样在电子邮件模板中执行此操作,方法是添加与此答案非常相似的多部分多类型边界解决方案:
base64 encoded images in email signatures
现状:
(客户端)模板:
<template name="feedback">
<h1>The Image</h1>
<img src="{{image}}" alt=""/>
</template>
(客户端)调用邮件功能:
var dataContext={
image: canvas.toDataURL('image/png')
};
var html=Blaze.toHTMLWithData(Template.feedback, dataContext);
Meteor.call('feedback', html);
(服务器端):
Email.send({
to: 'xxx',
from: 'xxx',
subject: 'xxx',
html: html
});
预期结果:一封带有嵌入图像的精美电子邮件。
实际结果: 我收到邮件部分 html,部分 'raw' 文本。我不知道为什么。
这是我在原始电子邮件中看到的部分内容:
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<h1>The Image</h1>
=20=20=20=20<img =
src=3D"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAALKCAYAAADTWUxrAA
有什么想法吗?
Gmail 以及许多其他客户端不允许您在 img 标记中使用 base64 作为源。不过有一些方法可以解决这个问题:
第一个也是最简单的可能是将图像保留在您的服务器上并将 url 放入图像源标记中。这具有能够处理一些跟踪的额外好处(需要一些额外的开发)。
第二种方法是使用第三方邮件系统,将图像和 HTML 发送给他们,并以这种方式进行设置。出于多种原因,这可能是好的,但它并不能真正回答您的问题。
最后,您可以像现在这样在电子邮件模板中执行此操作,方法是添加与此答案非常相似的多部分多类型边界解决方案:
base64 encoded images in email signatures