← Back to context

Comment by jeroenhd

3 years ago

IMAP UIDs aren't unique IDs per message, they are an incrementing number assigned to a message that's unique per mailbox ("folder"). Their incrementing nature is part of the standard, a random number would likely break mail clients. They should be stable between sessions but when you move a message back and forth between folders, the UID changes every time.

There are events where the UIDs change, for example when a server needs to rebuild its indices after corruption, but those should be extremely rare. Your server should also show this change when asked for UIDVALIDITY.

A message is defined by (UID, UIDVALIDITY, folder name). If this tuple changes, the message needs to be refetched. It's not the best mechanism for supporting multiple mail clients at once but it's easy to implement at least.

BTW, "unique per-mailbox" utterly fails to be sufficient in a post-gmail labels-as-folders world. That's because folders are lame. But doing better than folders really makes you want a relational database for email.