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
Pdoexception' with Message 'Sqlstate[22001]: String Data, Right Truncated: 0
Hide Added to Cart Message in Woocommerce
What's the Best Way/Practice to Get the Extension of a Uploaded File in PHP
Extract Dom-Elements from String, in PHP
Pull Random Line from Txt File as String
Redirect to 'Www' Before Ssl Requirement
Can a PHP Function Accept an Unlimited Number of Parameters
Php, Why Do You Escape My Quotes
How to Get Column Names from Pdo's Fetchall Result
PHP - Fastest Way to Check Presence of Text in Many Domains (Above 1000)
Add a Shipping to an Order Programmatically in Woocommerce 3
How to Convert a PHP Query String into a Slash-Based Url
Check How Many Times Specific Value in Array PHP
Setting a Cookie in an Ajax Request
What Is the Easiest Way to Use the Head Command of Http in PHP