Can I rely on the "Date: " email header?
Asked Answered
D

1

5

I've got a few maildirs I grabbed with getmail (both inbox and sent) and I want to give the eml files names that represent the date and time each mail has arrived (or was sent):

[email protected]+0000.eml

(I want Windows to read the files, so no colons)

I've noticed that there is only one occurence of "Date: " inside the eml files:

Date: Tue, 28 Jul 2015 20:02:14 +0000

Can I rely on this piece of header to rename the files? Is it reliable?

(I plan to write a posix or bash script for this task)

Deegan answered 28/7, 2015 at 21:18 Comment(0)
P
9

Short answer: nope.

The Date header (and most of the other headers) is set by the client (and is not required), so it could be just anything or absent.

Spams appart, since the Date field is set by the MUA(/MSA) and still a lot of people are not synced with NTP or did not care to configure their working station properly, it is more than often wrong. I also often see missconfigured automated mailer or MTA...

The date found in the Received headers is slightly more trustworthy because it is set by the realying MTA and the probability they are well configured is higher.

Note that except for the last one (the top-most in appearing order) which is your server (in your case GMail) they can be forged too.

Pessimism answered 28/7, 2015 at 21:23 Comment(3)
I'm viewing an eml file and I'm seeing the exact opposite: Received: from imap.gmx.com (XXX.XXX.XXX.XXX:993) by playbox.example.org with IMAP4-SSL; 19 Sep 2014 00:46:11 -0000 and Date: Fri, 09 May 2014 02:18:17 +0200. I received the mail on 2014-05-09 and I fetched it with getmail on 2014-09-19.Deegan
"slightly more trustworthy" — there is no guarantee that a Mail Transfer Agent will even have a clock set to the right century, and for some MTAs, there's good reason to assume they won't. For example, someone stuck this box in a closet in the 1990s and its hardware clock has gotten way out off but it still delivers the mail so no one even knows it exists.Barnaba
getmail isn't an MTA but it modified the Received date! I'm reading this <en.wikipedia.org/wiki/Mail_retrieval_agent> and I think that I probably need to see some of its configuration options.Deegan

© 2022 - 2024 — McMap. All rights reserved.