我想用 PHPMAiler 发送时事通讯。时事通讯确实有效,但我想知道是否有更好的选择来做到这一点。
我有的是。
- 网页
- 图片
现在我的代码如下所示
$mail = new PHPMailer();
//Adding the body
$body = file_get_contents('template/index.htm');
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view this message, please use an HTML compatible email viewer!";
$mail->SetFrom('xxxxxxx', 'xxxxxxxxxx');
$address = ".......@gmail.com";
$mail->AddAddress($address, "xxxxxxx");
$mail->AddEmbeddedImage("template/images/bullet_point.gif","1");
$mail->AddEmbeddedImage("template/images/template_1_01.gif","2");
$mail->AddEmbeddedImage("template/images/template_1_03.gif","3");
$mail->MsgHTML($body);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
我使用 file_get_contents 来获取 html 页面,并使用 AddEmbeddedImage 来嵌入图像,现在有没有办法只将 HTML 页面传递给 PHPMailer 并且 PHP Mailer 会自动嵌入这些图像?