使用PHPMailer来发送带图片的 HTML Emails
2018-07-20 来源:open-open
<?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"; } ?>
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
上一篇:python实现的堆排序算法代码
下一篇:C# 检查应用是否已经运行的代码
最新资讯
热门推荐