procmail
[Top] [All Lists]

Why not trust the From_ date?

2004-07-25 10:59:17
* Google Kreme <gkreme(_at_)gmail(_dot_)com> [2004-07-25 09:16]:

Thye dn't at all do the same thing.  One simply gets the year from
the Date: header and the other scans the received headers for the
right timestamp and rebuilds a corrected From_ header based on it.

I just examined the code, and can see the difference.  

But why would we rebuild the From_ timestamp?  Doesn't the MTA replace
that timestamp when it receives the message - in which case the
replaced timestamp should match the one constructed from the received
line?  I just looked at some of my recent mail, and the timestamp on
the From_ line already matches that of the Received line for my
server.

Well, you can adapt the script I posted to scan the Date header
then.  It will be hard because you can't predict the Date: header
format with certitude. Try doing a grep -e "^Date:" on your mail and
just do a quick visual scan to see how the formats stack up.

Here's a sample from my own mailboxes of some differing formats:

List Replies:Date: Tue, 02 Mar 2004 11:24:15 +1300

I grep'd older mail, and got results like that above, but with even
more variation.  Sometimes the date was like 97-10-02, or 5-13-99.  

are just a few of the formats I ran into.  I don't know how well GNU
date will handle all of those formats (I suspect it might just be
able to), but if you can do something like

date -d "`formail -X Date:` +%a %b %d %H:%M:%S %Y"

and get a result then that's great.

GNU date seems to be pretty tolerant.  It can handle all of the
variations you posted, and can even parse the 97-10-02 date.  What it
cannot parse is the MM-DD-YY format because it blindly takes the month
to be the year; which is a little disappointing, because GNU date
could be a little more intelligent and know that numbers >31 must be a
year.  

So gnu date still has room for improvement.  It would be nice if you
could feed gnu date a pile of junk (like a complete Received field
with an embedded date), and have it pick out the date.

I don't have access to GNU date myself, so the point is a bit moot
for me. (dunno how it would get along with freeBSD anyway).

I guess it does make sense to have procmail scripts that replicate
other tools, because some environments are limited.  Some companies
run procmail in a very restricted shell (smsh or something like that),
and I think formail, procmail, and sendmail are the only commands
available in those environments.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail