Guest User

Untitled

a guest
Sep 2nd, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. problem in sending mail by gmail smtp in server but works fine in localhost
  2. <?php
  3.  
  4. require_once "Mail.php";
  5.  
  6. $from = "username@gmail.com";
  7. $to = "username@yahoo.com";
  8. $subject = "Hi!";
  9. $body = "Hi,nnHow are you?";
  10.  
  11. $host = "ssl://smtp.gmail.com";
  12. $port = "465";
  13. $username = "username@gmail.com";
  14. $password = "*****";
  15.  
  16. $headers = array ('From' => $from,
  17. 'To' => $to,
  18. 'Subject' => $subject);
  19. $smtp = Mail::factory('smtp',
  20. array ('host' => $host,
  21. 'port' => $port,
  22. 'auth' => true,
  23. 'username' => $username,
  24. 'password' => $password));
  25.  
  26.  
  27. $mail= $smtp->send($to, $headers, $body);
  28. if (PEAR::isError($mail)) {
  29. echo("<p>" . $mail->getMessage() . "</p>");
  30. } else {
  31. echo("<p>Message successfully sent!</p>");
  32. }
  33.  
  34. ?>
Add Comment
Please, Sign In to add comment