I see this topic has been discussed years ago, but I recently started
running some MailMan lists and this problem came up almost as soon as I
started running it. (Version 2.1.5)
Users WILL NOT set their clocks to some nicely synchronized time. This
is especially true since many of my subscribers are computer neophytes.
When sorted by date, some replies come before the original posting. The
worst offender is actually a highly competent computer user who claims
to have a defective clock in his laptop that produces messages from the
year 2080. (The truth of his claim is immaterial.) In an ideal world,
these things would never happen. This is not an ideal world.
There was a discussion about "not munging" the headers as a validation
for objecting to altering the "Date" header. Considering the actions of
"CookHeaders.py" and other files that variously alter the "Reply To"
header, delete unwanted headers, and obviously alter the "Subject" line,
these objections seem weak, if not ironic. The date set by the senders
computer is not sacrosanct. While it may have some "meaning," it is of
no "use." Also, if the date isn't set properly, it probably isn't even
important to the sender.
Since all of these messages are, in fact, being sent by my server I
think it quite reasonable to change the "Date" to reflect the time that
it was processed and changed by the server. I'm the one who has to
answer questions about why the archive dates seem wrong and who is
ultimately responsible for the smooth operation of the service. I would
LIKE this to be an option that I could set. I do not have the time or
inclination to write the code to make this a user option. However,
since it something I wanted applied to all of my lists, I added the code
to copy the "Date" field to "X-Original-Date" and put in the server's
time as the "Date."
Suddenly, my new archives are coherent. I don't have to worry about
aberrant or obnoxious users. I only added six lines of code (and two
imports) to "CookHeaders.py" to make this work. PLEASE tell me I wasted
my time and there is a simple option I can set! Tell me that I don't
have to port this code when I want to upgrade!
I don't speak Python, and I know I imported more than necessary, but it
seems to work. I'm including the code changes both to share what I
found to be Very Useful and to have others sanity-check my code. As I
said, I never wrote a line of Python before this.
PS I considered sending this message from the year 2080 as I've had to
deal with, but I thought I'd give you a chance to implement this patch
PPS No, I don't WANT there to be a "fuzzfactor" allowing "close enough"
dates. Server Time Only.
# SKuck Header additions to CookHeaders.py of Mailman 2.1.5 - Nov 18, 2004
from email.Utils import parsedate_tz, mktime_tz, formatdate
# End SKuck Header additions
msg['List-Id'] = listid_h
# The above included as an insertion location reference. I think
it'll work from anywhere in "def process"
# SKuck added to pounce on bad email time stamps.
originaldate = msg.get('date')
receivedtime = formatdate(time.time())
msg['Date'] = receivedtime
msg['X-Original-Date'] = originaldate
# End SKuck added