Guest User

Untitled

a guest
Sep 23rd, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1.  
  2. <?php
  3. require_once "Mail.php";
  4.  
  5. $from = "Web Master <webmaster@example.com>";
  6. $to = "Nobody <nobody@example.com>";
  7. $subject = "Test email using PHP SMTP\r\n\r\n";
  8. $body = "This is a test email message";
  9.  
  10. $host = "mail.emailsrvr.com";
  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. 'auth' => true,
  20. 'username' => $username,
  21. 'password' => $password));
  22.  
  23. $mail = $smtp->send($to, $headers, $body);
  24.  
  25. if (PEAR::isError($mail)) {
  26. echo("<p>" . $mail->getMessage() . "</p>");
  27. } else {
  28. echo("<p>Message successfully sent!</p>");
  29. }
  30. ?>
Add Comment
Please, Sign In to add comment