使用PHPMailer发送电子邮件 - 将图像嵌入正文 [英] Send email with PHPMailer - embed image in body

查看:347
本文介绍了使用PHPMailer发送电子邮件 - 将图像嵌入正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHPMailer发送带有图像的HTML邮件。
身体是从包含所有信息的html文件加载的。



发送邮件时,图像不会显示在正文中,尽管我甚至发送图像也作为附件。



HTML < img> 标记指向与



PHP:

  $ mail-> AddAttachment 'IMG / 2u_cs_mini.jpg'); 

如何使html指向附件,以便可以将图像加载到正文中。 / p>

看看PHPMailer附带的示例,我没有注意到任何差异,在他们的情况下,图像确实出现。

解决方案

我找到答案:

  $ mail-> AddEmbeddedImage img / 2u_cs_mini.jpg','logo_2u'); 

< img> 标签把 src ='cid:logo_2u'


I'm trying to send HTML mail, with PHPMailer, with images. The body is loaded from a html file, that contains all the info.

When sending the mail, the image does not appear in the body, although I even send the image also as an attachment.

HTML <img> tag points to the same place as the place.

PHP:

$mail->AddAttachment('img/2u_cs_mini.jpg');

How can I make the html point to the attachment so the image can be loaded in the body.

Looking at the example that comes with PHPMailer I do not notice any difference, and in their case the image does appear.

解决方案

I found the answer:

$mail->AddEmbeddedImage('img/2u_cs_mini.jpg', 'logo_2u');

and on the <img> tag put src='cid:logo_2u'

这篇关于使用PHPMailer发送电子邮件 - 将图像嵌入正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆