1

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

Return-Path: <xxxxxx@gmail.com>
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 <xxxxxxxx@gmail.com>
        (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??

Krishna Chebrolu
  • 145
  • 2
  • 13
  • Have you checked the server date-time ? – Tamilvanan Nov 03 '17 at 05:35
  • https://stackoverflow.com/questions/31309536/how-to-set-time-zone-in-codeigniter –  Nov 03 '17 at 05:38
  • server date-time is fine. date_default_timezone_set('Asia/Kolkata') is also set require "modules/Database.class.php"; require "modules/constants.php"; //require "vendor/swiftmailer/lib/swift_required.php"; require "vendor/autoload.php"; date_default_timezone_set('Asia/Kolkata'); use Monolog\Logger; use Monolog\Handler\StreamHandler; global $db,$mail,$log; // create a log channel $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output $mail->isSMTP(); // Set mailer to use SMTP – Krishna Chebrolu Nov 03 '17 at 07:00
  • Don't post details of question or code in comments. Post them in your question itself. – Xpleria Nov 03 '17 at 09:22
  • How do you expect us to comment on your code if you don't post it? One obvious problem is that you can't use `tls` encryption mode on port 465; it should be 587 or 25, but the inclusion of the `ssl://` prefix on your `Host` value is overriding that which is why it isn't breaking. Also why are you loading both SwiftMailer **and** PHPMailer? Pick one! – Synchro Nov 03 '17 at 09:43
  • @Synchro I noticed that `sendmail` daemon was started on 31-mar-2017. Also, **Date** header is not set on the generated email. As per `phpmailer` documentation, system date will be picked up if **Date** header is empty. However, it appears that daemon start date & time is stamped on generated email. How should this be addressed? Thanks – Krishna Chebrolu Nov 21 '17 at 14:51
  • PHPMailer sets the date header automatically, unless you override it (by setting the `MessageDate` property). Your mail server may also be doing something with it. – Synchro Nov 21 '17 at 15:08
  • 1
    Thanks @Synchro. The issue is solved after setting the `clock` with correct timezone as per this [link](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html) – Krishna Chebrolu Nov 22 '17 at 10:22

1 Answers1

0

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

Krishna Chebrolu
  • 145
  • 2
  • 13