On Thu, 24 Jun 2004, David Feldman wrote:
How does one (at both the IMAP command and c-client level) check for new mail efficiently in all a user's mailboxes at once?

The short answer is: you can't.

The longer answer is:

Identify a set of mailboxes which merit further probing, and focus your checking on them.

In a strictly "check all mailboxes" environment, do a LIST and note which mailboxes come back with \Marked status (if you're paranoid, then choose the mailboxes which don't have \Unmarked status). Then do a STATUS on each of these to check them further, or just SELECT them if the user wants them opened.

Alternatively, have a discrimination between "incoming" mailboxes and mailboxes which are strictly archive. Don't even consider the archive mailboxes, which for most users greatly overwhelm the number of incoming mailboxes. If you are a reasonable number of incoming mailboxes, then just have all of these mailboxes SELECTed in separate IMAP sessions; this is the most efficient, best real-time, and least-costly way to monitor a set of mailboxes.

Put another way; 5 IMAP sessions monitoring 5 mailboxes is less costly (often *MUCH* less costly) than repeatedly probing those 5 mailboxes in one IMAP session. Sessions are cheap, especially if you use the IDLE command. Polls are not cheap, especially with mail stores that oblige the server has to parse the enter mailbox to satisfy a STATUS.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.

Reply via email to