0

This is what I get when running the PHPMailer script on the production server. PHPMailer version is 5.1

SMTP -> ERROR: Failed to connect to server: Network is unreachable (101)
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error:
Could not connect to SMTP host

PHPMailer Configuration

$mail->IsSMTP();
$mail->SMTPDebug  = 1;
$mail->SMTPAuth   = true;                  
$mail->SMTPSecure = "ssl";                 
$mail->Host       = "smtp.gmail.com";      
$mail->Port       = 465;                   
$mail->Username   = "xxxx@gmail.com";  
$mail->Password   = "xxxx";

Using this config, it worked perfectly on localhost running XAMPP.

What I Tried

$mail->SMTPSecure = "tls"; // no luck

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

$mail->SMTPKeepAlive = true; // no luck

$mail->Port = 587; // no luck

$mail->Port = 25; // no luck

I tried with various combinations of the above but still I got the error message displayed above.

FYI, my localhost is on Windows while the server is on Linux. Don't know if that would cause a problem, but just wanted to put it out there.

4

0 回答 0