Welcome Guest, Not a member yet? Register   Sign In
Email shows date in the past?
#1

[eluser]vanquish[/eluser]
I am using the CodeIgniter Email Class to send emails to myself and to customers.

However, there is a very strange problem which is causing a lot of confusion for us. The emails are being timestamped with the wrong date, which causes them to display out of order in the client's inbox.

For example, I just sent an email today, August 24 at 1:48pm MST. Our server is running on PST (only 1 hour west of us). I checked my inbox and the email was time stamped as August 23, 6:41pm MST.

I cannot find any documentation relating to this issue. Does anyone have any clue as to what would be the reason for this strange bug??

Here is the basic code:
Code:
$this->load->library('email');

$config['charset'] = 'iso-8859-1';
$config['mailtype'] = 'html';

$this->email->initialize($config);

$this->email->from('[email protected]', 'Company Name');
$this->email->to($_SESSION['user_email']);

$this->email->subject('Some info for you');
$this->email->message($this->load->view('customer_email_view', $data, TRUE));    

$this->email->send();
#2

[eluser]mddd[/eluser]
Check the email's headers. It could also be that the server on the receiving end has the wrong time and the client sorts on 'received time' instead of 'sent time'.
In the full headers you should find a list of servers that the email passed through, each with a date/time so you can track where it went wrong.
#3

[eluser]vanquish[/eluser]
Here are the full headers. (Personal addresses and domains are of replaced for privacy reasons):

Any idea what's happening here? I am by no means an expert on email systems.

Code:
From - Tue Aug 24 01:41:40 2010
X-Account-Key: account2
X-UIDL: 31500-1108612714
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000
X-Mozilla-Keys:                                                                                
Return-path: <[email protected]>
Received: from pd5mr1no-ssvc.prod.shaw.ca
(pd5mr1no-ssvc.prod.shaw.ca [10.0.153.212])
by l-daemon (Sun Java System Messaging Server 6.2-7.05 (built Sep  5 2006))
with ESMTP id <0L7N003QYC1D7DY0@l-daemon> for [email protected]; Tue,
24 Aug 2010 01:41:38 -0600 (MDT)
Received: from unknown (HELO pd5mi2no-ssvc.prod.shaw.ca) ([10.0.153.22])
by pd5mr1no-svcs.prod.shaw.ca with ESMTP; Tue, 24 Aug 2010 01:41:33 -0600
Received: from unknown (HELO abc123.com) ([72.47.212.82])
by pd5mi2no-dmz.prod.shaw.ca with ESMTP; Tue, 24 Aug 2010 01:41:33 -0600
Received: (qmail 9303 invoked by uid 48); Tue, 24 Aug 2010 00:41:32 -0700
Date: Tue, 24 Aug 2010 00:41:32 +0000
From: actBig Sales <[email protected]>
Subject: =?iso-8859-1?Q?Some_info_for_you?=
X-Sender: [email protected]
To: [email protected]
Reply-to: "[email protected]" <[email protected]>
Message-id: <[email protected]>
MIME-version: 1.0
X-Mailer: CodeIgniter
Content-type: multipart/alternative;
boundary="Boundary_(ID_mTFuvq/3W7eeLtpLruzJiA)"
X-Priority: 3 (Normal)
X-Cloudmark-SP-Filtered: true
X-Cloudmark-SP-Result: v=1.0 c=1 a=V4Ieh6d1QroA:10 a=jPJDawAOAc8A:10
a=nvgWl49OzIkA:10 a=VphdPIyG4kEA:10 a=6BSed4fE5IAaKsEAuvy2sQ==:17
a=ou8WzydnAAAA:8 a=NGcO-0mSwFSqPQRNfMoA:9 a=Ho8h3T41YQDogv0D9CgA:7
a=CRTgKAin2Z4pJlhfotH3iVQgQ84A:4 a=wPNLvfGTeEIA:10 a=-V5isYFobLsA:10
a=PS4qMcUsoTUA:10 a=uMwsqH211SXfDU3d:21 a=HK5-F4MS7uL6MjWZ:21 a=SSmOFEACAAAA:8
a=7Ee7F90c2ELm9-HTOv8A:9 a=6xFkKIyK59snMLgkn2UA:7
a=5wj97or_ci2SC7ep6UCF8EOWM1QA:4 a=4qIkh4CE9USS7Hlj:21 a=AlsDbGhSu3smswcL:21
User-Agent: CodeIgniter
Original-recipient: rfc822;[email protected]

This is a multi-part message in MIME format.
Your email application may not support this format.

--Boundary_(ID_mTFuvq/3W7eeLtpLruzJiA)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 8BIT
#4

[eluser]vanquish[/eluser]
I noticed that August 23, 6:41pm +7 hrs = August 24, 1:41pm - which is approximately the time I sent the email.

It must be a date/time conversion issue. But what is it exactly? I have never seen this kind of issue before.
#5

[eluser]mddd[/eluser]
Looking at this, the times of all the servers seem ok. The only one that is wrong is the Date set by CI when sending the email:
Code:
Date: Tue, 24 Aug 2010 00:41:32 +0000
CI looks at the timezone offset of your server using the php function date('Z');
It seems that your webserver has the timezone set incorrectly (it thinks it's on GMT).
So check your server's settings..
#6

[eluser]vanquish[/eluser]
[quote author="mddd" date="1282655947"]Looking at this, the times of all the servers seem ok. The only one that is wrong is the Date set by CI when sending the email:
Code:
Date: Tue, 24 Aug 2010 00:41:32 +0000
CI looks at the timezone offset of your server using the php function date('Z');
It seems that your webserver has the timezone set incorrectly (it thinks it's on GMT).
So check your server's settings..[/quote]

I changed the date.timezone value in PHP.INI to America/Edmonton and it shows when I run phpinfo(); I also did the same update in my Plesk control panel

However, I still get the wrong time on the email.

Any other ideas? Thanks so much for the help so far! I think the solution is just around the corner here...
#7

[eluser]vanquish[/eluser]
I ran date('Z'); and it gave me a value of -21600. So I don't know how CodeIgniter missed that. I am not quite familiar with the CodeIgniter code base - looking through the code has not given me any clues.
#8

[eluser]mddd[/eluser]
Where does that "From" line come from? That's not an email header is it?
My guess is that that line is put there by your email client for index purposes.

The thing you should be looking at is the "date" header. The one I quoted in my post.
#9

[eluser]vanquish[/eluser]
[quote author="mddd" date="1282660449"]Where does that "From" line come from? That's not an email header is it?
My guess is that that line is put there by your email client for index purposes.

The thing you should be looking at is the "date" header. The one I quoted in my post.[/quote]

Yes, you are correct. Even so, the date header still shows this:
Code:
Date: Tue, 24 Aug 2010 18:38:49 +0000
#10

[eluser]vanquish[/eluser]
I checked another server that I am running CodeIgniter on, and the emailing sending is working fine on that one.

Dates on the 2nd server are showing as Date: Mon, 23 Aug 2010 12:14:32 -0600

I ran date('r') in a PHP file on the problem server and it gave me this:

Tue, 24 Aug 2010 19:05:05 -0600

So the server time is set correctly, but somehow CodeIgniter screws up the email headers!




Theme © iAndrew 2016 - Forum software by © MyBB