Hi Im trying to send mail through SMTP using gmails smtp server. But the problem is I get a Failed to connect error. I dont know what I'm doing wrong. Perhaps someone could give insight of why the problem is occurring
Here is my code:
<?php
require_once('Mail.php');
$to = 'example@example.com';
$headers['From'] = 'example@example.com';
$headers['Subject'] = 'New Version of PHP Released!';
$body = 'Go to http://www.php.net and download it today!';
$params = array('host' => 'ssl://smtp.gmail.com', 'port' => '587', 'auth' => true,
'username' => 'example@example.com', 'password' => 'blah blah');
$message =& Mail::factory('smtp', $params);
$result = $message->send($to, $headers, $body);
if (PEAR::isError($result)) {
echo "{$result->getMessage()}";
}
else {
'Message successful';
}
?>
I get the following error:
Failed to connect to ssl://smtp.gmail.com:587 [SMTP: Failed to connect socket: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:587 (Unknown error) (code: -1, response: )]
Regards