0
votes

We have to develop a Message Store using a IMAP interface that should have the functionality of Persistent UIDs so that later those messages can be synchronized across multiple devices (like mobile, PC, Laptop) and the device can delete / copy the messages. RFC 3501 mentions UIDs are unique within the session.

So my question is: does any IMAP RFC talk about the persistent UID for a mailbox?

2
What's wrong with IMAP? You're probably going to want to be compatible with it.84104

2 Answers

2
votes

Every IMAP message is assigned a UID that is specific to the user, as in two users may receive two different messages, but be assigned the same UID. [aka UID != UUID] If your software is issuing a simple FETCH 1:* (FLAGS) the server will respond with a sequentially numbered list disregarding the message's UID. Any command in which you want to deal specifically with a message's UID you must be sure that you're issuing it properly, as in FETCH UID 1:* (FLAGS).

eg:

a1 fetch 1:* (flags)
* 1 FETCH (FLAGS (\Seen))
* 2 FETCH (FLAGS (\Seen))
* 3 FETCH (FLAGS (\Seen))
* 4 FETCH (FLAGS (\Seen))
* 5 FETCH (FLAGS (\Answered \Seen))
* 6 FETCH (FLAGS (\Seen))
* 7 FETCH (FLAGS (\Seen))
* 8 FETCH (FLAGS (\Seen))
* 9 FETCH (FLAGS (\Seen))
* 10 FETCH (FLAGS (\Seen))

versus:

a8 uid fetch 1:* (flags)
* 1 FETCH (UID 1 FLAGS (\Seen))
* 2 FETCH (UID 2 FLAGS (\Seen))
* 3 FETCH (UID 3 FLAGS (\Seen))
* 4 FETCH (UID 4 FLAGS (\Seen))
* 5 FETCH (UID 5 FLAGS (\Answered \Seen))
* 6 FETCH (UID 6 FLAGS (\Seen))
* 7 FETCH (UID 8 FLAGS (\Seen))
* 8 FETCH (UID 9 FLAGS (\Seen))
* 9 FETCH (UID 10 FLAGS (\Seen))
* 10 FETCH (UID 11 FLAGS (\Seen))

That said, I don't understand why you need to track the UIDs separately to synchronize across multiple devices. So long as each device is gathering its information from the IMAP server they will be in sync by default. You're essentially re-implementing functionality that already exists in any IMAP server.

1
votes

What RFC3501 mandates is that the UIDs must remain constant within a session. This does not mean that they should not be perisstent across sessions -- on the opposite, unless they are persistent, the IMAP clients will have to download them all the time.

I would suggest to re-read the relevant portions of RFC3501 several times here -- this is a crucial piece of the IMAP mailbox synchronization and it is important to get this right -- including the relations with UIDVALIDITY and UIDNEXT, as well as the CONDSTORE and QRESYNC extensions.

Also please keep in mind that there are pretty strict guarantees on how the UIDs are assigned and what the UID of a newly arriving message must look like. Having a per-server unique identifier is not enough.