UID uniqueness of IMAP mails

emailimap

In our internal webmail system, we'd like to attach notes and contacts to certain mails. In order to do this, we have to keep track of every mail on our IMAP server.

Unfortunately the IMAP standard doesn't enforce the uniqueness of the UID of a mail in a mailbox (just in subfolders). Is there any tool/IMAP server which generates UIDs which are truly unique? Or is there any other way how we can identify each mail? (the Message-ID header field is not unique as some mails do not contain such a field).

Additional resources:
Unique ID in IMAP protocol – Limilabs.com

Best Answer

A tuple of (folder name, folder UIDVALIDITY, message UID) distinguishes a message from all others in an IMAP account. For any given message, that tuple can change between sessions, so you might want to track its Message-ID as a backup in case this happens.

Yes, it really is that annoying.