Best way for email synchronisation: POP3 UIDL, IMAP UID, message-ID

2.2k Views Asked by At

I'm making a mail client which work POP3 and IMAP. I'm programming the client in C++ with vmime api. My question is: What is the best way for synchronizing mail?

I think that identificator is good way but I don't know what is the best identificator for synchronize mail:

  • IMAP: UID (RFC 3501)
  • POP3: UIDL (RFC 1932)
  • Internet format message: message-ID (RFC 5322)

message-ID is the easiest to use but is it possible that there are two identical message-ID? Same question for UID (IMAP) and UIDL (UID)?

can you help me? Thank you in advance.

2

There are 2 best solutions below

0
On BEST ANSWER

While Max is right in saying that a tuple of (FolderName, UIDVALIDITY, UID) will never ever refer to any other message, there's unfortunately no guarantee that a given message will be always referred to only using that same tuple. Servers are allowed to bump the UIDVALIDITY, and there's no standard way of providing unique identifiers which persist across message moves or identify duplicate messages.

0
On

In IMAP, the tuple of (FolderName, UIDVALIDITY, UID) is guaranteed, by specification, to be forever unique for a given server. Note that all three values are needed to guarantee uniqueness. Each folder has it's own UIDs, which may overlap. A deleted and renamed folder may have the same UIDs as well, but must have different UIDVALIDITYs.

In POP3, UIDL is generally sufficient, since there are no folders.

Message-IDs are generated by the sender, generally, so cannot be guaranteed to be unique. It's trivial to duplicate this: copy a message from one IMAP folder to another.