Hi all,
I am trying to configure PHPMailer for using it with Google Apps.
When I call the function I get this error:
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
And after about 10 seconds, this one also:
SMTP Error: Could not connect to SMTP host.
I researched about this error and I have checked the e-mail address/password. It works fine as I am able to log into Google mail using them
I also checked the port 465, using “telnet smtp.gmail.com 465” I got no error message, but also not an answer from the server, just a black screen.
This is the finction I am using, if anyone can point me where the error is, I’d apreciate it a lot.
Username and Password are just examples)
<?php
require(“/home/libroman/public_html/phpmailer/PHPMailer_5.2.0/class.phpmailer.php”);
function smtpmailer($to, $from, $from_name, $subject, $body) {
global $error;
$mail = new PHPMailer(); // create a new object
$mail->SMTPSecure = “ssl”;
$mail->Host=‘smtp.gmail.com’;
$mail->Port=‘465’;
$mail->Username = ‘myemail@mydomain.com’; // SMTP account username
$mail->Password = ‘password’;
$mail->SMTPKeepAlive = true;
$mail->Mailer = “smtp”;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->CharSet = ‘utf-8’;
$mail->SMTPDebug = 0;
$mail->SetFrom($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send()) {
$error = 'Mail error: '.$mail->ErrorInfo;
return false;
} else {
$error = 'Message sent!';
return true;
}
}
?>
Thanks a lot!!!