首頁  >  文章  >  後端開發  >  使用PHPMailer來傳送帶有圖片的 HTML Emails

使用PHPMailer來傳送帶有圖片的 HTML Emails

WBOY
WBOY原創
2016-07-25 08:42:531276瀏覽
  1. require("class.phpmailer.php");
  2. $mail = new PHPMailer();$mail = new PHPMailer();
  3. $mail->IsSMTP();
  4. $mail->Host = "smtp1.example.com;smtp2.example.com";
  5. $mail->SMTPAuth = true;
  6. $mail->Username = 'smtpusername';
  7. $mail->Password = 'smtppassword';
  8. $mail->From="mailer@example.com";
  9. $mail->FromName="My site's mailer";
  10. $mail->Sender="mailer@example.com";
  11. $mail->AddReplyTo("replies@example.com", "Replies for my site");
  12. $mail->AddAddress("email@example.com");
  13. $mail->Subject = "Test 1";
  14. $mail->IsHTML(true);
  15. $mail->AddEmbeddedImage('logo.jpg', 'logoimg', 'logo.jpg'); // attach file logo.jpg, and later link to it using identfier logoimg
  16. $mail->Body = "

    Test 1 of PHPMailer html

  17. This is a test picture:

    ";
  18. $mail->AltBody="This is text only alternative body.";
  19. if(!$mail->Send())
  20. {
  21. echo "Error sending: " . $mail->ErrorInfo;;
  22. }
  23. else
  24. {
  25. echo "Letter is sent";
  26. }
  27. ?>
复制代码

PHPMailer、HTML、電子郵件


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn