Posted By

erraja_07 on 02/26/11


Tagged

mail function


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

HomoLogicus


PHP - Mailer Code


 / Published in: PHP
 

URL: http://www.vpsdiscussions.com/index.php/topic,111.0.html

Advance Mail function using PHP Mailer Class

  1. <?php
  2. require("class.phpmailer.php");
  3.  
  4. $mail = new PHPMailer();
  5.  
  6. $mail->IsSMTP(); // send via SMTP
  7. $mail->Host = "smtp.domain.com"; // SMTP servers
  8. $mail->SMTPAuth = true; // turn on SMTP authentication
  9. $mail->Username = "[email protected]"; // SMTP username
  10. $mail->Password = "password"; // SMTP password
  11.  
  12. $mail->From = "[email protected]";
  13. $mail->FromName = "Name";
  14. $mail->AddAddress("[email protected]","Name");
  15. $mail->AddReplyTo("[email protected]","Your Name");
  16.  
  17. $mail->WordWrap = 50; // set word wrap
  18.  
  19. $mail->IsHTML(true); // send as HTML
  20.  
  21. $mail->Subject = "Here is the subject";
  22. $mail->Body = "This is the <b>HTML body</b>";
  23. $mail->AltBody = "This is the text-only body";
  24.  
  25. if(!$mail->Send())
  26. {
  27. echo "Message was not sent <p>";
  28. echo "Mailer Error: " . $mail->ErrorInfo;
  29. }
  30.  
  31. echo "Message has been sent";
  32.  
  33. ?>

Report this snippet  

You need to login to post a comment.