首页  >  文章  >  后端开发  >  使用PHPMailer来发送带图片的 HTML Emails

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

WBOY
WBOY原创
2016-07-25 08:42:531279浏览
  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: 使用PHPMailer来发送带图片的 HTML Emails

    ";
  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, Emails


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn