我已将以下参数添加到 PHPMailer 对象。虽然我使用 AddEmbeddedImage() 函数嵌入了用于内联目的的图像,但它按预期工作,但另外附加了相同的图像作为电子邮件的附件并在底部显示。
$msg = `<table><tr><td colspan="2"><img src="cid:header_jpg" alt="www.example.in" width="770" height="4" border="0" /></td></tr></table>`;
$mail = new PHPMailer(true); //New instance, with exceptions enabled
$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = false; // enable SMTP authentication
$mail->Port = 25; // set the SMTP server port
$mail->Host = 'localhost'; // SMTP server
$mail->Username = ""; // SMTP server username
$mail->Password = ""; // SMTP server password
$mail->AddReplyTo($sender, $sender_name);
$mail->From = $sender;
$mail->FromName = $sender_name;
$mail->AddAddress($receiver);
$mail->Subject = $subject;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap
$mail->MsgHTML($msg);
$mail->IsHTML(true); // send as HTML
$mail->AddEmbeddedImage('./images/header.jpg', 'header_jpg');
$mail->AddEmbeddedImage('./images/logo.jpg', 'logo_jpg');
$mail->AddEmbeddedImage('./images/alert_icon.png', 'alert_icon_png', 'alert_icon.png');
$mail->Send();
请尽早提出一些建议...