您可以将内联base64编码图像添加到Mandrill模板吗? [英] Can you add inline base64 encoded image to a Mandrill template?
问题描述
我使用Mandrill模板来确保我的所有电子邮件都相同外观和感觉,我有一个简单和小的标志,我喜欢添加到我的模板,遵循以下建议:
http://help.mandrill.com/entries/25252978-Tips-for-using-images-in-Mandrill-emails
然而,我不确定在何处以及如何在我的HTML模板中添加必需的代码。任何人都有一个想法,如果可能,怎么办?
Thx
我可能已经找到了我自己的问题的答案。
否 - Mandrill不允许您添加内联图片或上传图片附件作为模板的代码。
解决方案 - 您需要将数组[images]添加到API中的建议的$消息中。
这是一个PHP示例函数:
//将cid图像添加到$ message
函数add_email_logo($ message){
$ logo = array(
'images'=> array(
array(
'type'=>'image / png',
'name'=>'logo',
'content'=>'iVBORw0KGgoAAAANSUhEUgAA ....等'
)
)
);
return array_merge($ message,$ logo);
}
并使用图像src =cid :{name}
< img src =cid:logo/>
Does anyone know if and how-to add a Base64 encoded image to a Mandrill Template.
I use a Mandrill template to make sure all my emails have the same look and feel and I have a simple and small logo which I'd prefer to add to my template following these recommendations: http://help.mandrill.com/entries/25252978-Tips-for-using-images-in-Mandrill-emails
However i'm unsure on where and how to add the neccesary code in my HTML template. Anyone have an idea if it's possible and how-to do it?
Thx
I have probably found the answer to my own questions.
NO - Mandrill doesn't allow you to add an inline image or to upload the image attachment as code to the template.
SOLUTION - you need to add the array [images] to the $message as suggested in the API.
Here is an PHP example function to do it:
// Add cid image to $message
function add_email_logo($message) {
$logo = array (
'images' => array (
array (
'type' => 'image/png',
'name' => 'logo',
'content' => 'iVBORw0KGgoAAAANSUhEUgAA....etc.'
)
)
);
return array_merge( $message, $logo);
}
and use the image src="cid:{name}"
<img src="cid:logo"/>
这篇关于您可以将内联base64编码图像添加到Mandrill模板吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!