I\'m implementing a IMAP client, and I have a problem with IMAP mailbox synchronization.
First, it is okay to fetch new mails from IMAP server, but I don\'t know how to
The usual approach is to execute the following two IMAP commands for each folder:
. EXAMINE ""
. FETCH 1:* (UID FLAGS)
The first command selects a folder and returns the UIDVALIDITY of this folder. If this value matches the previously returned UIDVALIDITY for this folder, you can rely on the UIDs. The second command returns (at least) the UID and all FLAGS for each mail in the selected folder.
\Seen
) and deleted mails (\Deleted
).This approach is used by many IMAP clients, and most IMAP servers are optimized for them. The limiting factor is usually the available network bandwidth between client and server.
The following situations are a bit more complicated: