使用PHPMailer来发送带图片的 HTML Emails

2015-06-22 0 531
使用PHPMailer来发送带图片的 HTML Emails
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';
 
$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
$mail->Sender="mailer@example.com";
$mail->AddReplyTo("replies@example.com", "Replies for my site");
 
$mail->AddAddress("email@example.com");
$mail->Subject = "Test 1";
 
$mail->IsHTML(true);
$mail->AddEmbeddedImage('logo.jpg', 'logoimg', 'logo.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg
$mail->Body = "<h1>Test 1 of PHPMailer html</h1>
    <p>This is a test picture: <img src=\"cid:logoimg\" /></p>";
$mail->AltBody="This is text only alternative body.";
 
if(!$mail->Send())
{
   echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
   echo "Letter is sent";
}
?>

遇见资源网 php 使用PHPMailer来发送带图片的 HTML Emails http://www.ox520.com/7895.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务