Reputation: 83
I'm using PHPMailer
for sending mail with authentication, but i'm getting the following message when i tried to run my sendmessage.php.
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
can anyone please tell me why i'm getting this message...and some solution for this
Mycode is as given below
sendmessage.php
<html>
<head>
<title>PHPMailer - SMTP (Gmail) basic test</title>
</head>
<body>
<?php
//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "myemailid@gmail.com";
$mail->Password = "myemailpassword";
$mail->SetFrom('myemailid@gmail.com','vgvb');
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress('myfriendemailid');
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
</body>
</html>
Upvotes: 0
Views: 10871
Reputation: 4179
The issue might be your firewall blocking the smtp.gmail.com, instead give the IP Address it should work
74.125.129.108
Upvotes: 0
Reputation: 11
Open php.ini file from WAMP and verify that openssl.dll is uncommented .
Upvotes: 1