PHPMailer SMTP Could not connect to SMTP host error — timezone issue?

We use WordPress and PHPMailer for sending email via SMTP. A few weeks ago, our email stopped working and this was brought to my attention yesterday. I did some testing yesterday, using the Advanced Email Options plugin for WordPress.

On Server 1, when I test email, I get a debug response including, “SMTP Error: Could not connect to SMTP host.”.

To test to make sure it is not our SMTP server, I stood up a new FreeBSD VM with WordPress (Server 2). When I tested the email using the same SMTP configuration, the email was sent successfully.

From the debug log from both servers, it appears that the issue is being caused by a bad datetime on Server 1.

Here are the current datetime values on each server,

Server 1
FreeBSD – date returns Thu May 25 10:34:00 EDT 2017
Wordpress – Settings > General > Timezone = “New York” and shows the following data, Universal time (UTC) is 2017-05-25 14:34:00. Local time is 2017-05-25 10:34:00
PHP – date.timzone = America/New_York, but Server(“Request_Time”) returns 1495722896, which = May 25, 2017, 2:34 pm
Advanced Email Plugin in WordPress – Message Date = string(31) “Thu, 25 May 2017 14:37:24 +0000”

If I explicitly set date.timezone in php.ini, why doesn’t it show this time in the phpinfo()?

Read more here: PHPMailer SMTP Could not connect to SMTP host error — timezone issue?

Leave a Reply

Your email address will not be published. Required fields are marked *