Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2017
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2. require_once("Mail.php");
  3.  
  4. $from = "Your Name <email@blahblah.com>";
  5. $to = "Their Name <otheremail@whatever.com>";
  6. $subject = "Subject";
  7. $body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit...";
  8.  
  9. $host = "mailserver.blahblah.com";
  10. $username = "smtp_username";
  11. $password = "smtp_password";
  12.  
  13. $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);
  14.  
  15. $smtp = Mail::factory('smtp', array ('host' => $host,
  16.                                      'auth' => true,
  17.                                      'username' => $username,
  18.                                      'password' => $password));
  19.  
  20. $mail = $smtp->send($to, $headers, $body);
  21.  
  22. if ( PEAR::isError($mail) ) {
  23.     echo("<p>Error sending mail:<br/>" . $mail->getMessage() . "</p>");
  24. } else {
  25.     echo("<p>Message sent.</p>");
  26. }
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement