PHPMailer fails to connect:
Mailer error: SMTP connect() failed. [
github.com]
I have followed the suggested troubleshooting hits in the refered link:
i) DNS resolution working (verified)
ii) Disabling firewall does not resolve issue
iii) Opensll loaded (per PhpInfo output)
iv) I used a test script to test and request SMTPDebug=4. Script and error messages are posted below. The exact same script tested on
Linux LAMP stack server and works fine but fails in Windows 10 WampServer installation.
Following post suggests php_smtp.dll is needed, I don't know enough to know:
[
thewwwbloggers.blogspot.com]
I appreciate any help.
1 - Windows 10 64 Bits
2 - Version WampServer: wampserver3_x64
3 - Apache Version: apache2.4.17
4 - PHP Version: php5.6.16
5 - MySQL Version: mysql5.7.9
6 - WampServer icon: Green
7 - c:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
::1 localhost
8 - Localhost access OK
9 - phpMyAdmin access OK
11 - Antivirus Avast
Firewall Windows integrated firewall
12 - Wampserver Path C:\wamp64
10 - Error Message Relates
Test Script:
<?php
require("PHPMailerAutoload.php"
; // path to the PHPMailerAutoload.php file.
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "smtp.gmail.com";
$mail->Port = "587"; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Username = "cjsdfw@gmail.com";
$mail->Password = "********";
$mail->SMTPDebug = 4; // enables SMTP debug information (for testing)
$mail->From = "cjsdfw@gmail.com";
$mail->FromName = "Carlos";
$mail->AddAddress("cjsdfw@HOTMAIL.COM", "Carlos"
;
$mail->AddReplyTo("cjsdfw@gmail.com", "Carlos"
;
$mail->Subject = "Hi";
$mail->Body = "Hi! How are you?";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo '<br>'.'Message was not sent.'.'<br>';
echo 'Mailer error: ' . $mail->ErrorInfo;
exit;
} else {
echo 'Message has been sent.';
}
?>
Error Message:
2016-03-31 09:02:56 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ( )
2016-03-31 09:02:56 Connection: opened 2016-03-31 09:02:56 SMTP -> get_lines(): $data is ""
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "220 smtp.gmail.com ESMTP 70sm1588168ual.12 - gsmtp "
2016-03-31 09:02:56 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 70sm1588168ual.12 - gsmtp 2016-03-31 09:02:56 CLIENT -> SERVER: EHLO joomla
2016-03-31 09:02:56 SMTP -> get_lines(): $data is "" 2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] "
2016-03-31 09:02:56 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] "
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250-SIZE 35882577 " 2016-03-31 09:02:56 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] 250-SIZE 35882577 "
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250-8BITMIME "
2016-03-31 09:02:56 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] 250-SIZE 35882577 250-8BITMIME "
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250-STARTTLS " 2016-03-31 09:02:56 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS "
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES "
2016-03-31 09:02:56 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250-PIPELINING "
2016-03-31 09:02:56 SMTP -> get_lines(): $data is "250-smtp.gmail.com at your service, [External-IP-Address-Masked] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING "
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "250 SMTPUTF8 "
2016-03-31 09:02:56 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [External-IP-Address-Masked] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250 SMTPUTF8
2016-03-31 09:02:56 CLIENT -> SERVER: STARTTLS
2016-03-31 09:02:56 SMTP -> get_lines(): $data is ""
2016-03-31 09:02:56 SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS "
2016-03-31 09:02:56 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2016-03-31 09:02:56 SMTP Error: Could not connect to SMTP host.
2016-03-31 09:02:56 CLIENT -> SERVER: QUIT
2016-03-31 09:02:56 SMTP -> get_lines(): $data is ""
2016-03-31 09:02:56 SMTP -> get_lines(): $str is ""
2016-03-31 09:02:56 SERVER -> CLIENT:
2016-03-31 09:02:56 SMTP ERROR: QUIT command failed:
2016-03-31 09:02:56 Connection: closed
2016-03-31 09:02:56 SMTP connect() failed. [
github.com]