Answers:
我找到了答案:
$mail->AddEmbeddedImage('img/2u_cs_mini.jpg', 'logo_2u');
并在<img>
标签上src='cid:logo_2u'
echo "src=\"cid:logo_2u\""
,我不认为反斜杠是必需的。
根据PHPMailer手册,完整答案将是:
$mail->AddEmbeddedImage(filename, cid, name);
//Example
$mail->AddEmbeddedImage('my-photo.jpg', 'my-photo', 'my-photo.jpg ');
用例:
$mail->AddEmbeddedImage("rocks.png", "my-attach", "rocks.png");
$mail->Body = 'Embedded Image: <img alt="PHPMailer" src="cid:my-attach"> Here is an image!';
如果要显示带有远程URL的图像:
$mail->addStringAttachment(file_get_contents("url"), "filename");