MessageID headers are often missing, even though that is "invalid". I've also got thousands of examples of messages with identical MessageID values. (Largely from automated systems that use some trivial/broken template to generate the emails.)
I needed this when i was working on my engineering project, and added 'processed' flags for already processed items. This way i could query all unprocessed items with "UNSEEN UNKEYWORD <flag>".
* https://tools.ietf.org/html/rfc3501#section-2.3.2
UIDS are more than simple 'message numbers'; they are part of a tuple (Folder, UIDVALIDITY, UID). It may be easy to think of UIDVALIDITY as a kind of 'generation number': for a given folder, as long as the UIDVALIDITY has not changed/incremented, the UID-to-messege has to be the same per the spec.
Though recently the OBJECTID extension has been published:
A UIDVALIDITY change should blow your whole cache. In practice they are rare.
Thank you for saving me from the heartbreak of finding this out later. Seriously you just saved me a ton of time.
>A UIDVALIDITY change should blow your whole cache. In practice they are rare.
So even in a huge pile of mail, everything would have to be reprocessed. Since it's so rare, I'm definitely going to set up metrics to monitor when it does happen. Do you have any insight on how people store the mail? Do they actually use the UID to reference it or is it used as more of a cursor?
So I'm working on an app that uses IMAP. I need to know which emails I've already processed. Has anyone ever used the message ID header to identify an email as unique/seen? Or do you hash the email in its entirety? Or is there some other way to do it?
I guess what I'm still confused about is determining how to handle a UID validity change. So I'm afraid to use UIDs.