在谷歌应用引擎Php上发送内联电子邮件附件


Sending inline email attachments on Google App Engine Php

如何在appengine php中嵌入内联图像?它需要base64吗?我看到了消息-> addAttachment但我如何在我组装的html中引用它?

对于swiftmailer,我只需要

$SMap = PUBLIC_ROOT . "images/sample.jpg";
$type = pathinfo($SMap, PATHINFO_EXTENSION);
$data = file_get_contents($SMap);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
$ImageCode = "<img style='"padding:0 50px 0 0;'" src='"" . $base64 .     "'" alt='"Image'" />";

,只是插入图像显示代码在我想要的地方,但我没有看到任何参考资料,或者我不能找到它的原因php appengine原生电子邮件。

内联附件使用content-id完成。文档源

$image_data = file_get_contents($SMap);
// Notice that $image_data is the raw file data of the attachment.
$ImageCode = "<img style='"padding:0 50px 0 0;'" src='"cid:img1'" alt='"Image'" />";
$message = new Message();
$message->setSender("from@google.com");
$message->addTo("to@google.com");
$message->setSubject("Example email");
$message->setHtmlBody($ImageCode);
$message->addAttachment('image.jpg', $image_data, "img1");
$message->send();
相关文章: