Fix dates via IMAP on messages

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Fix dates via IMAP on messages

David Orman
Hi,

I've got a curious problem. Due to a bad migration many years ago (via maildir cp's) by one of the admins at my ISP, I've got a mess when trying to view webmail. The webmail client (no, this is not something I can change) relies on server-date for email dates, instead of looking at the email headers. The server-based date for the mail is of course the file creation/modification time, and cp -p was not used apparently.

All of my new mail is fine (I run my mailserver now) but my mail from about 7-10 years ago is all the date of the migration. Is there any program out there that will read the headers of the mail and change the server-date of the files? I've tried imapsync with -syncinternaldate, to see if it read headers, but it doesn't. I just want to be able to run the command on the user/imap server of choice, and have it read all the mail headers, and set the creation dates properly on the mails (all via IMAP).

Any help would be much appreciated!
David
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

Cody Baker-2
I doubt there's anything out there automagically does it, but it
wouldn't be terrible to write.  "In theory" (With huge sarcastic quotes
around that) the e-mail dates follow the format described at
http://www.w3.org/Protocols/rfc822/#z28 .   There's probably a lot of
messages that deviate from that, but by in large you should be able to
use them.  Just use a text processing language (like Perl), pull out the
date field, and convert it into the format accepted by touch and modify
the file date from that.  Recurse through all of the files and enjoy.

Thank You,

Cody Baker
[hidden email]


David J. Orman wrote:

> Hi,
>
> I've got a curious problem. Due to a bad migration many years ago (via maildir cp's) by one of the admins at my ISP, I've got a mess when trying to view webmail. The webmail client (no, this is not something I can change) relies on server-date for email dates, instead of looking at the email headers. The server-based date for the mail is of course the file creation/modification time, and cp -p was not used apparently.
>
> All of my new mail is fine (I run my mailserver now) but my mail from about 7-10 years ago is all the date of the migration. Is there any program out there that will read the headers of the mail and change the server-date of the files? I've tried imapsync with -syncinternaldate, to see if it read headers, but it doesn't. I just want to be able to run the command on the user/imap server of choice, and have it read all the mail headers, and set the creation dates properly on the mails (all via IMAP).
>
> Any help would be much appreciated!
> David
> _______________________________________________
> [hidden email] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-isp
> To unsubscribe, send any mail to "[hidden email]"
>  

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

Lyndon Nerenberg (VE6BBM/VE7TFX)
In reply to this post by David Orman
> All of my new mail is fine (I run my mailserver now) but my mail from
> about 7-10 years ago is all the date of the migration. Is there any
> program out there that will read the headers of the mail and change the
> server-date of the files? I've tried imapsync with -syncinternaldate, to
> see if it read headers, but it doesn't. I just want to be able to run
> the command on the user/imap server of choice, and have it read all the
> mail headers, and set the creation dates properly on the mails (all via
> IMAP).

I'm not aware of a tool that will do this, but writing a program to handle
this is trivial. All it needs to do is read the message until you find the
date header, parse the date, then call utimes() to update the file's
mtime.

If you need an RFC822 date parser, look for the infamous getdate.y.

--lyndon
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

Darren Pilgrim-2
Lyndon Nerenberg wrote:

>> All of my new mail is fine (I run my mailserver now) but my mail from
>> about 7-10 years ago is all the date of the migration. Is there any
>> program out there that will read the headers of the mail and change
>> the server-date of the files? I've tried imapsync with
>> -syncinternaldate, to see if it read headers, but it doesn't. I just
>> want to be able to run the command on the user/imap server of choice,
>> and have it read all the mail headers, and set the creation dates
>> properly on the mails (all via IMAP).
>
> I'm not aware of a tool that will do this, but writing a program to
> handle this is trivial. All it needs to do is read the message until you
> find the date header, parse the date, then call utimes() to update the
> file's mtime.

It's far from trivial using the Date header.  When I had to do the same
post-migration Maildir fix-up David is talking about, I found the format
of the Date: header varied so widely that I ended up with tens of
thousands (out of an archive of ~300k emails) of messages whose Date
headers stumped the date-grokking functions in Perl and Visual Basic.

What *is* pretty standard is the timestamps in Received headers.  I
don't have any messages on hand that were relayed through qmail, but
Postfix, Sendmail and a handful of common Windows "enterprise" mail
servers all use the same format[1] and place it immediately at the only
semi-colon in the header.  Since the "Date" on IMAP messages is the
message creation time, not the Date header, on most IMAP servers, the
timestamp in the top-most Received header is usually pretty close to the
date of actual message delivery.

[1] "%e %b %Y %T" in strftime(3) parlance.

--
Darren Pilgrim

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

Lyndon Nerenberg (VE6BBM/VE7TFX)
> It's far from trivial using the Date header.

Oh bugger off.  Rick Adams' getdate.y can handle pretty much anything you
throw at it.  Face it: it dealt with all the crap bnews threw at it for
close to two decades.

--lyndon
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

Sean Winn
It is far from trivial; there's a huge variety of just completely  
weird/ambiguous date formats placed in Date:, usually by spamware  
(time zone non-existent or invalid? times that don't even exist due  
to DST? 01/02/2005 - is that Feb 1 or Jan 2? Guess by time zone ...  
or is 'EST' US or AU EST?). It'd be great if they were the only  
source - tag them at epoch, and they all get sorted out of the way.  
Unfortunately, there's a bunch of broken mail servers/clients out  
there just as bad, from people who've never read the RFCs. Trusting  
the Received header placed by your own mail server is usually a  
better idea - it's at least consistent, and matches what should be  
the time stamp on the maildir files rather than some clients idea of  
time. I wish I'd thought of it during migration to courier I had to do.

On 19/07/2006, at 4:01 PM, Lyndon Nerenberg wrote:

>> It's far from trivial using the Date header.
>
> Oh bugger off.  Rick Adams' getdate.y can handle pretty much  
> anything you throw at it.  Face it: it dealt with all the crap  
> bnews threw at it for close to two decades.
>
> --lyndon
> _______________________________________________
> [hidden email] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-isp
> To unsubscribe, send any mail to "[hidden email]"
>

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

Lyndon Nerenberg (VE6BBM/VE7TFX)
> It is far from trivial;

Again: oh bugger off.

getdate.y groks anything that is (usefully) valid.  The rest you should
just throw in the bit bucket.  Why make life miserable for yourself?

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Fix dates via IMAP on messages

David Orman
Thank you to the two gentleman who gave me useful input. I think I'll  
go about it how you said, I checked a few random messages out of the  
bunch and the received date looked correct. Good enough for me, I  
just need the dates to be somewhere in the correct ballpark, a few  
minutes makes no difference (these are mails from 7 years ago.. who  
are we kidding..)

To the guy with the huge chip on his shoulder, if you don't have  
something helpful to say, don't say anything. I looked at the  
getdate.y you keep mentioning the first time you brought it up, no  
need to slam other people who are attempting to help, and have VALID  
points. I don't need all 40830484 spam mails that are stuck in my  
archive suddenly popping up as my most recent mail, that would be a  
NIGHTMARE. I'd *much* rather work off the received by date stamp. I  
appreciated your input the first time, and I thank you for it, but  
really - no need to be so abrasive to other people trying to help. It  
just so happens I like their solution best.

Cheers,
David

On Jul 18, 2006, at 8:36 PM, Lyndon Nerenberg wrote:

>> It is far from trivial;
>
> Again: oh bugger off.
>
> getdate.y groks anything that is (usefully) valid.  The rest you  
> should just throw in the bit bucket.  Why make life miserable for  
> yourself?
>
> _______________________________________________
> [hidden email] mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-isp
> To unsubscribe, send any mail to "[hidden email]"

_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "[hidden email]"