Trying to send SMTP mail through pear mail, Gmail account - connection times out
Hello,
I'm trying to use Wamp to send an email. When I run this script the page loads and my error log says that Mail/mail.php times out. I'm only sending the email to one person and i'm curious what the problem is. I would really appreciate your help. Other combinations of SMTP port as 25 and smtp as localhost don't work, they say failed to connect to mailserver. Again, thanks for helping me out.
Here's the script - I'm running this by opening the page in my browser.
<?php
ini_set("include_path", ".;C:\wamp\bin\php\php5.3.0\PEAR"
;
ini_set("smtp_port", 465);
ini_set("SMTP", "smtp.gmail.com"
;
ini_set("sendmail_from", "kburke11@students.claremontmckenna.edu"
;
ini_set("auth_username", "kburke11@students.claremontmckenna.edu"
;
ini_set("auth_password", "mypassword"
;
$m = include('Mail.php');
include('Mail/mime.php');
ini_set('memory_limit','1000M');
$text = 'Text version of email';
$html = 'Hello!';
$crlf = '\r\n';
echo 'This is working so far';
$hdrs = array(
'From' => 'kburke11@cmc.edu',
'Subject' => 'Test html message'
);
echo 'This is working so far';
$mime = new Mail_mime();
print_r($mime);
echo 'This is working so far2';
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
//do not ever try to call these lines in reverse order
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
echo 'This is working so far2';
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "kburke11@students.claremontmckenna.edu";
$password = "mypassword";
$mail =& Mail::factory('mail',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password,
'debug' => TRUE));
echo 'This is working so far3';
$recipient = array('kburke11@cmc.edu');
if (PEAR::isError($mail->send($recipient, $hdrs, $body))) {
die("Couldn't send mail"
;
}
echo $result;
?>