Phpmailer Error: Smtp -> Error: Failed to Connect to Server

PHPMailer SMTP ERROR: Failed to connect to server

Your configuration might be wrong. I believe that if you change your host into smtp.gmail.com it might solve your problem.

I noticed that you set security tls but you want to connect with ssl as well.

Change $mail->Host = "ssl://smtp.gmail.com"; into $mail->Host = "smtp.gmail.com"; and security to ssl.

From this answer:

$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 = "email@gmail.com";
$mail->Password = "password";
$mail->SetFrom("example@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("email@gmail.com");

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

SMTP connect() failed PHPmailer - PHP

You need to add the Host parameter

$mail->Host = "ssl://smtp.gmail.com"; 

Also, check if you have open_ssl enabled.

<?php
echo !extension_loaded('openssl')?"Not Available":"Available";

SMTP ERROR: Failed to connect to server: Connection timed out (110) when using phpmailer

I'm using a Linode Server, they blocked port 25, 465, 587, so I can't send mail and telnet smtp.gmail.com.
for more infomation, ckick here.

Problem with PHPMailer.Failed to connect to server?

You must have an account on a SMTP server, for example: smtp.googlemail.com (and easiest to get), so you can set like this:

$mail->Host = 'smtp.googlemail.com';
$mail->SMTPAuth = true;
$mail->Username = 'YOUR_GOOGLE_USERNAME'; // NOT email address to send to
$mail->Password = 'YOUR_GOOGLE_PASSWORD';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;


Related Topics



Leave a reply



Submit