[Imap-protocol] Checking for new messages
sflist at ihonk.com
Sun Jan 6 19:50:10 PST 2008
I'm implementing software which picks up and processes new email from
various IMAP servers. It logs in, does its thing, then logs out. The
accounts which are being checked are not being exclusively checked by my
software, so there are no guarantees about any flags being set on
messages, such as \Recent or \Seen. I need to avoid processing any
messages twice, and I'm not allowed to miss any new messages. (Nor am I
allowed to delete any messages.)
With POP3, determining whether new messages have arrived is quite
straightforward: Store a list of UIDs from past connections, then do a
UIDL on the POP3 server and compare the results.
With IMAP4, it seems to be more complicated, but I hope I'm missing
something here. I can't use message sequence numbers in any way to do
this, because they're unstable (since deleting a message decrements all
sequence numbers above that of the deleted message). And I can't use
UIDs if, like I'm experiencing when dealing with the Courier IMAP
server, I get a new UIDVALIDITY number every time I connect to the
server and open a mailbox.
So what's left? SEARCH SINCE? Is that going to find something new if the
date information in the message's header is wrong? And since I can only
narrow down to a day, I'm still going to have to look at headers to
determine whether I've seen the message before, right?
Any help would be appreciated.
More information about the Imap-protocol