Guest User

Untitled

a guest
Jul 29th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. How do I set up Pear mail?
  2. <?php
  3. require_once "Mail.php";
  4.  
  5. $from = "Sandra Sender <sender@example.com>";
  6. $to = "Ramona Recipient <recipient@example.com>";
  7. $subject = "Hi!";
  8. $body = "Hi,nnHow are you?";
  9.  
  10. $host = "ssl://mail.example.com";
  11. $port = "465";
  12. $username = "smtp_username";
  13. $password = "smtp_password";
  14.  
  15. $headers = array ('From' => $from,
  16.   'To' => $to,
  17.   'Subject' => $subject);
  18. $smtp = Mail::factory('smtp',
  19.   array ('host' => $host,
  20.     'port' => $port,
  21.     'auth' => true,
  22.     'username' => $username,
  23.     'password' => $password));
  24.  
  25. $mail = $smtp->send($to, $headers, $body);
  26.  
  27. if (PEAR::isError($mail)) {
  28.   echo("<p>" . $mail->getMessage() . "</p>");
  29.  } else {
  30.   echo("<p>Message successfully sent!</p>");
  31.  }
  32. ?>
  33.  
  34. require_once "/home/my_user/php/Mail.php";
Add Comment
Please, Sign In to add comment