Search code examples
codeignitersmtpphpmailersendmail

PHPMailer is sending with incorrect "date"


I have an issue with my code. All emails are sent with same date "31-mar-2017". here's the mail notification.

Return-Path: <[email protected]>
Received: from ip-172-31-29-190 (ec2-xx-xxx-xx.xx.ap-south-1.compute.amazonaws.com. [xx-xxx-xx.xx])
        by smtp.googlemail.com with ESMTPSA id a81sm7358557pfe.32.2017.11.02.08.27.05
        for <[email protected]>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 02 Nov 2017 08:27:06 -0700 (PDT)
Date: Fri, 31 Mar 2017 21:40:26 +0530

Can't figure out what the problem is... Appreciate your help.

Edit-1:

I have inherited this code. Following config is found:

defined('SMTP_HOST')   ? null : define("SMTP_HOST", "ssl://smtp.googlemail.com");
defined('SMTP_PORT')   ? null : define("SMTP_PORT", "465");
defined('SMTP_SECURE')   ? null : define("SMTP_SECURE", "tls");

Edit-2:

Our implementation is similar to How to build an email queue with PHPmailer?. ie., all emails are written to a jobs table and then picked up for processing.

The issue is emails are not working on my local and Test servers. However, they work on Production :(

It's becoming a herculean task to figure out why these things are not working on local and Test servers when the sample code https://github.com/phpmailer/phpmailer works perfectly fine on both.

This issue need to be solved prior to looking to the original issue posted here. No emails in the mail queue. Any pointers??


Solution

  • Well, the issue was not related to phpmailer or associated configuration.

    Even setting the date_default_timezone_set('Asia/Kolkata') didn't help.

    At the end, updating system clock and rebooting the server as per Setting the Time for Your Linux Instance fixed the incorrect date issue.

    Regarding emails not working on Test Server, my predecessor used supervisord to handle these processes. I had to just start that daemon as it wasn't part of init.d.

    Thanks