Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php
  2. require_once "Mail.php";
  3.  
  4. $from = "Web Master <webmaster@example.com>";
  5. $to = "Nobody <nobody@example.com>";
  6. $subject = "Test email using PHP SMTP with SSL\r\n\r\n";
  7. $body = "This is a test email message";
  8.  
  9. $host = "ssl://SMTPhostname";
  10. $port = "465";
  11. $username = "webmaster@example.com";
  12. $password = "yourPassword";
  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