在邮件正文phpmailer类中添加嵌入式图像 [英] Adding embedded images within mail body phpmailer class
本文介绍了在邮件正文phpmailer类中添加嵌入式图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在邮件正文中嵌入图片,但最终以附件的形式出现
Im trying to embed an image within my message body but it ends up as an attachment
$mailer->Subject = APP_NAME . " - " . $name . " send you and Ad : " . $row['name'];
$mailer->IsHTML(true);
$mailer->AddEmbeddedImage('../images/namDiams.png', 'logoimg', 'namDimes.png');
//footer
$footer = "Regards<br/><br/>";
$footer .= '<table style="width: 95%">';
$footer .= '<tr>';
$footer .= '<td>';
$footer .= "<strong><span style='font-size: 15px'>NamDimes Team</span></strong><br/>
NamDimes<br/>
Contact Number: " . APP_CONTACT . "<br/>
Email: " . APP_EMAIL . "<br/>
Website: " . APP_WEBSITE . "<br/>";
$footer .= '</td>';
$footer .= '<td style="text-align:right">';
$footer .= '<img src=\"cid:logoimg\" />';
$footer .= '</td>';
$footer .= '</tr>';
$footer .= '</table>';
$mailer->Body = $body . $footer;
$mailer->AltBody="This is text only alternative body.";
$mailer->AddAttachment('../' . $row['image_path'], $row['name'] . ".jpg");
我已经设置了其他所有内容,包括地址,邮件被发送出去,要嵌入到主体中的徽标图像作为附件附加,有人知道为什么吗?
i have set everything else, including the addresses, the mail gets send out, logo image that I want embed in the body gets attached as an attachment, anyone know why?
推荐答案
不使用$mailer->AddEmbeddedImage
,而是直接添加
<img src="http://.../images/namDiams.png" />
代替.
邮件长度应该更短...而且行得通.
The mail length should be lighter... And it works.
编辑
我不知道这是否对您有帮助,但是这里有一个小错误:
I don't know if it will help you but there is a little mistake here :
$mailer->AddEmbeddedImage('../images/namDiams.png', 'logoimg', 'namDimes.png');
应该是
$mailer->AddEmbeddedImage('../images/namDiams.png', 'logoimg', 'namDiames.png');//the last param the second 'a' was missing...
另一个主题此处
这篇关于在邮件正文phpmailer类中添加嵌入式图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文