【发布时间】:2013-08-29 00:36:25
【问题描述】:
我在 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();
请尽早提出建议...
【问题讨论】:
-
下次你可以在编辑器中使用Ctrl+K或
{}按钮格式化代码,无需在每一行添加<br/>。 -
谢谢@Maerlyn :)