Closed alexsdesign closed 6 years ago
Can you turn on SMTP debugging in PHPMailer, grab the logs, and post them here, so we can take a look?
(Tip: use the code formatting tool in the editor title bar to render code. Please make that change now, so that your code is readable for current and future readers).
The code was pasted inbetween the code "quote marks" so I don't know why that occurred, apologies.
SMTP Debugging is turned on... and set to 2 ... client and server side.
$mail->SMTPDebug = 2;
The total response is:
2018-01-31 21:13:03 SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed.
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent. Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
With SMTPDebug turned off ( set to 0 ) I get the following:
Message could not be sent. Mailer Error: SMTP connect() failed. Https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
You're not getting any SMTP debug output because it's not getting as far as talking SMTP - it's failing at the network level. I'd guess that your ISP is blocking outbound SMTP. The telnet tests in the troubleshooting guide will confirm that. You probably need to refer to their docs or ask them to enable SMTP.
The code is running on my own colocated server. I'm currently running phpMailer 5 on a seperate domain (on the same server) and that connects with no issue.
I'll do some more testing and digging and see what I can work out. (The current setup is not using the composer built version, so I might try that next)
2018-02-05 02:38:08 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP r3sm10281083pgf.46 - gsmtp
2018-02-05 02:38:08 CLIENT -> SERVER: EHLO localhost
2018-02-05 02:38:08 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [103.77.46.221]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2018-02-05 02:38:08 CLIENT -> SERVER: STARTTLS
2018-02-05 02:38:08 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
2018-02-05 02:38:08 CLIENT -> SERVER: QUIT
2018-02-05 02:38:08
2018-02-05 02:38:08
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.
@arnabmunshi did you work out what the issue was? Thanks.
You've got a TLS failure after attempting STARTTLS, and you're connecting to gmail, which changed its root cert not so long ago to one that's not in many OS CA cert bundles. That's all covered in the troubleshooting guide - so try updating your local CA certs.
Using the latest version of PHP Mailer 6 ... downloaded by ZIP to desktop and uploaded to server. Attempted this on TWO servers: Windows 2016 and Centos 6 (Plesk Onyx).
Here is the example code I'm using with "personal" information faked (such as email address and password.
I'm using the basic example code provided by you guys but every time I run it, I get the following error:
I ran a check to see if Open SSL is loaded:
<?php echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."\n"; ?>
I can confirm that Open SSL is loaded on the server/domain and the domain is SSL enabled.Apologies if this is a known issue with a known fix ( Or just my shoddy coding )... I have searched but nothing comes up for Version 6. If any more information is required please let me know.