Issues

ZF-2110: No Date header is added to mail messages before sending

Description

If a date header is not set while assembling the message it needs to be added before sending.

From: KyleMac nabble@deletethetrees.com Subject: Re: [fw-general] Zend_Mail

I was just looking into this missing date header thing since it caused a few emails to bounce. From what I can tell, the MTA is under no obligation to add the date header and in Exim it's considered a "fixup" (or rather, not doing it is called suppressing fixups). Short story; if your MTA adds it then it's being kind, if not then it's your fault for not doing it yourself.

Considering the date header is meant to be a requirement, I think that maybe it deserves at least a mention in the ZF manual, maybe it's own addDate() method and probably to be added automatically by Zend_Mail.

Matthew Weier O'Phinney-2 wrote:

On 7/6/06, Brent Robinson brent@arquila.com wrote:

I am having a problem with Zend_Mail that my mail is not passing a date header. I am getting a 01/01/1970 date in thunderbird and a unknown date in Webmail.

I am using SMTP and am developing on a Windows Platform with Apache 2 and PHP5.

Is there something that I am overlooking or am not setting. I have looked and googled the whole afternoon but cannot find anything.

Date headers are usually set by the mail transport; if you're not seeing one, then your transport isn't putting it in (which is bad behaviour on the part of the transport).

Two options: investigate your mail transport and see why it's not setting the date header, or set it manually using Zend_Mail's addHeader() method:

$mail->addHeader('Date', date('r'));

What are you using for mail delivery, by the way? You mention SMTP, but you don't specify what kind of SMTP server you're using. Others may be able to point out additional remedies based on that information.

</mailing list thread>

From RFC 2822: "[The origination date specifies] the time at which the human or other creator of the message has put the message into its final form, ready for transport."

Comments

Attached a patch that adds new setDate()/getDate() methods. If a date is not set before send()ing, it's automatically set.

Nico, will you have time to get to this by the PR code freeze (1/22)?

Thanks Jordan for the patch. It's added to trunk, with some modifications and should be fully tested (don't have xdebug installed here).