So, I just resolved my "SMTP Connection Error" error, and I wanted to post a solution just in case it helps someone else.
I used the EXACT code specified in the gmail.phps PHPMailer example file. It worked just when I used MAMP, and then I got an SMTP connection error as soon as I moved it to my personal server.
All the stack overflow answers I read and all the PHPMailer troubleshooting documentation says this is not a problem with PHPMailer. This is a server side configuration issue. I tried different ports (587, 465, 25), I tried "SSL" and "TLS" encryption. I checked that openssl is included in my php.ini file. I checked that the firewall problem was not there. Everything is checked, and still nothing.
The solution was that I had to delete this line:
$mail->isSMTP();
Now everything works. I don’t know why, but it works. The rest of my code is copied and pasted from the PHPMailer example file.
Evan Butler Jul 02 '15 at 21:12 2015-07-02 21:12
source share