Home > Backend Development > PHP Tutorial > Use PHPMailer to send HTML Emails with images

Use PHPMailer to send HTML Emails with images

WBOY
Release: 2016-07-25 08:42:53
Original
1292 people have browsed it
  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, Emails


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template