Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2. require_once "Mail.php";
  3.  
  4. $from = "IsmAvatar@gmail.com";
  5. $to = "IsmAvatar <IsmAvatar@gmail.com>";
  6. $subject = "Test";
  7. $body = "This is just a test";
  8.  
  9. // stick your GMAIL SMTP info here! ------------------------------
  10. $host = "ssl://smtp.google.com";
  11. $port = "465"; //or 587
  12. $username = "IsmAvatar@gmail.com";
  13. $password = "password";
  14. // --------------------------------------------------------------
  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.     'debug' => true,
  24.     'username' => $username,
  25.     'password' => $password));
  26.  
  27. $mail = $smtp->send($to, $headers, $body);
  28.  
  29. if (PEAR::isError($mail)) {
  30.   echo('<p>' . $mail->getMessage() . "</p>\n");
  31. //Failed to connect to ssl://smtp.google.com:465 [SMTP: Failed to connect socket: Connection timed out (code: -1, response: )]
  32.  } else {
  33.   echo("<p>Message successfully sent!</p>\n");
  34.  }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement