After migrating hosting providers last year, I have ended up with many emails that show up with a "Date" of the migration, rather than the message delivery date, see screenshot:
This date shows up both on my local clients (Mail.app in OS X 10.11.6 and iOS 10 beta) and also webmail (Roundcube).
The back-end mailserver is Dovecot, and all messages in the Maildir directory have the correct Delivery-date
headers.
Is there any way to correct this, or have Dovecot re-read or re-compile its message databases?
This actually turned out to be client-related, rather than Dovecot-related. Long story short, the Mail apps in both OSX and iOS actually use the filesystem
mtime
of the message file, rather than the message'sDate
orDelivery-date
headers.The (admittedly hacky) workaround was to write a quick script to read the appropriate header and
touch
all files to correct themtime
of the file, then clear all Dovecot cache files to the file is re-indexed.I believe Dovecot uses the Date: header. I've run into this issue when moving messages without a Date header. Some were from an old mail system, but most were from the Sent folder. Relatively few were sent by servers that didn't ensure the Date header was present.
You may be able to resolve this by adding the header and forcing it to reindex the folder. You may be able to use the
formail
utility to add the Date header. You may need to chain commands and create a new directory for the fixed email. If you have a Maildir format store, you may be able to move the cur subdirectory to a new name like old, and rewrite back to cur.