如何使用PHP邮件将Base64图像数据嵌入到电子邮件中?使用PHP邮件将基础64字符串嵌入到电子邮件中
<?php
$aImg = $_POST['aImage'];
$to = "[email protected]";
$subject = "Sending png image to email";
$message = "<html><head></head><body>";
$message .= '<img src="'.$aImg.'" alt="This is an Image" /></body></html>';
$headers = "Content-type: text/html";
if (mail($to, $subject, $message, $headers)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
我运行代码后,显示“消息发送成功”,但图像没有显示出来。它会显示一个小红十字图像。我一直在调试几个小时,但仍然无法让我的图像出来。目前,我正在将电子邮件发送到本地主机进行测试。
如何构建图像数据?你看过你电子邮件的html src,它是否与http://en.wikipedia.org/wiki/Data_URI_scheme相匹配? – archil
我通过将画布转换为PNG图像来构建。 var aImage = canvas [0] .toDataURL(“image/png”); – user1407415