Hey guys, I am trying to send email using my gmail account, and I'm getting an error for some reason. Would anyone know why it would give me this error? The script:
<?php
set_include_path("/usr/share/php");
include("Mail.php");
$from = "email <email address>";
$to = "<Emailaddress>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "smtp.gmail.com";
$username = "[email protected]";
$password = "myPassword";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
The Page resolves when I go to it, but gives the following error:
Failed to connect to smtp.gmail.com:25 [SMTP: Failed to connect socket: Connection refused (code: -1, response: )]