Synchronization

Synchronization Operations for Disconnected IMAP4 Clients RFC is useful for you to read.

Clients have two choices to look for new changes: polling, or waiting for server to send them with IDLE. With polling the client usually sends a NOOP command every few minutes. The client should also send CHECK command once in a while instead, e.g. every 15 minutes. With some servers only CHECK command checks for new changes.

If you use IDLE, make sure to break out of it every 29 minutes to make sure that the server doesn't kill the connection after 30 minutes of idling.

Don't send STATUS command to selected mailbox. It works more or less badly with many servers. Some simply refuse to respond to it, while with others it doesn't show the updated mailbox state (e.g. if you send only STATUS commands, new messages in selected mailbox aren't noticed). There should be no need for it anyway, you should know all the same information already (except UIDNEXT value).

IMAP4 Extensions for Quick Mailbox Resynchronization is a highly useful extension to implement.