Advertisement
Guest User

Untitled

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