SMTPAuth = true;$mail->Username = 'smtpusername';$ma">
当前位置:Gxlcms > PHP教程 > 使用PHPMailer来发送带图片的HTMLEmails

使用PHPMailer来发送带图片的HTMLEmails

时间:2021-07-01 10:21:17 帮助过:3人阅读

  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

人气教程排行