0

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 Answers2

2

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.

Sammitch
  • 30,782
  • 7
  • 50
  • 77
  • Possibly more appropriate as a separate question but imap uid's (can be|are just) simple integers? I must admit I was expecting them to look more like uuid's and how I read the imap RFC seemed to suggest they'd be like UUID's but I guess not? – David Mar 08 '14 at 10:23
  • In RFC3501 there are `Unique Identifier (UID)` and also `Message Sequence Number`. So the sequence number is in each mailbox 1,2,3,4... and the UID is unique system wide. Both are Integers but not UUIDs. UUID contains A-F0-9 and '-'. – TheFox May 21 '14 at 11:34
1

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.

Jan Kundrát
  • 3,700
  • 1
  • 18
  • 29