Advertisement
CaptainLepidus

PHP Sending Email

Mar 6th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Sending E-mail from PHP
  2.  
  3. Regular PHP mail functions may not be used with our mail servers as we have SMTP authentication enabled. Use the code below with the phpMailer to send e-mails. The username and password will need to be replaced with your e-mail username and password.
  4.  
  5. <?php
  6. require("class.phpmailer.php");
  7.  
  8. $mail = new PHPMailer();
  9.  
  10. $mail->IsSMTP(); // set mailer to use SMTP
  11. $mail->Host = "mail.reliablesite.net"; // specify server
  12. $mail->SMTPAuth = true; // turn on SMTP authentication
  13. $mail->Username = "emaillogin"; // SMTP username
  14. $mail->Password = "emailpassword"; // SMTP password
  15.  
  16. $mail->From = "fromemail@domain.com";
  17. $mail->FromName = "My Name";
  18. $mail->AddAddress("toemail@domain.com");
  19. $mail->AddReplyTo("fromemail@domain.com", "My Name");
  20.  
  21. $mail->WordWrap = 50; // set word wrap to 50 characters
  22. $mail->IsHTML(true); // set email format to HTML
  23.  
  24. $mail->Subject = "Here is the subject";
  25. $mail->Body = "This is the HTML message body <b>in bold!</b>";
  26. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  27.  
  28. if(!$mail->Send())
  29. {
  30. echo "Message could not be sent. <p>";
  31. echo "Mailer Error: " . $mail->ErrorInfo;
  32. exit;
  33. }
  34.  
  35. echo "Message has been sent";
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement