Author Topic: 1.6.1 Email Problem - error Recieved Date  (Read 3831 times)

vnju

  • Newbie
  • *
  • Posts: 17
    • View Profile
1.6.1 Email Problem - error Recieved Date
« on: January 09, 2010, 04:37:34 am »
Since I  upgraded 1.6.1 from 1.6.0, I've got the error: The  'Recieved date' field of new Email equal 1970-01-01
Thanks

vnju

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #1 on: January 13, 2010, 01:29:47 am »
no answer

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #2 on: January 19, 2010, 04:09:32 pm »
Do you mean emails you compose or emails you receive?

vnju

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #3 on: January 20, 2010, 12:09:31 am »
the new Emails I recieved.
I checked their 'recieved date'  field in database. All of them was 1970-01-01

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #4 on: January 20, 2010, 11:03:05 am »
I don't know if it's related, but what date format are you using?

vnju

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #5 on: January 22, 2010, 04:57:40 am »
The date format I used as d/m/Y . It's default
The value "1970-01-01" was shown in database. In application, It was displayed as Today. As in MailController.php file, at line 1877, I saw this codes

"date" => $msg->getReceivedDate() instanceof DateTimeValue ? ($msg->getReceivedDate()->isToday() ? format_time($msg->getReceivedDate()) : format_datetime($msg->getReceivedDate())) : lang('n/a'),
Can u give me a solution?
thanks

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #6 on: January 22, 2010, 03:12:40 pm »
So the background problem is that new email is being stored as received on '1970-01-01', right? Try changing file 'environment/classes/mail/MailUtilities.class.php' line 206 from:

Code: [Select]
if (array_key_exists("Date", $parsedMail)) {
$mail->setSentDate(new DateTimeValue(strtotime($parsedMail["Date"])));
}else{
$mail->setSentDate(new DateTimeValue(DateTimeValueLib::now()));
}
if (array_key_exists("Received", $parsedMail) && $parsedMail["Received"]) {
$mail->setReceivedDate(new DateTimeValue(strtotime($parsedMail["Received"])));
}else{
$mail->setReceivedDate(new DateTimeValue(DateTimeValueLib::now()));
}

to:

Code: [Select]
$sent_timestamp = false;
if (array_key_exists("Date", $parsedMail)) {
$sent_timestamp = strtotime($parsedMail["Date"]);
}
if ($sent_timestamp === false || $sent_timestamp === -1 || $sent_timestamp === 0) {
$mail->setSentDate(DateTimeValueLib::now());
} else {
$mail->setSentDate(new DateTimeValue($sent_timestamp));
}

$received_timestamp = false;
if (array_key_exists("Received", $parsedMail) && $parsedMail["Received"]) {
$received_timestamp = strtotime($parsedMail["Received"]);
}
if ($received_timestamp === false || $received_timestamp === -1 || $received_timestamp === 0) {
$mail->setReceivedDate($mail->getSentDate());
} else {
$mail->setReceivedDate(new DateTimeValue($received_timestamp));
}

vnju

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: 1.6.1 Email Problem - error Recieved Date
« Reply #7 on: January 25, 2010, 01:16:51 am »
Thank ignacio for your reply
However,it was not successfull, it has still get that error.
 :(
thanks