MBOX-Line: From mrc at CAC.Washington.EDU  Sun Jan  6 19:59:57 2008
To: imap-protocol@u.washington.edu
From: Mark Crispin <mrc@CAC.Washington.EDU>
Date: Fri Jun  8 12:34:41 2018
Subject: [Imap-protocol] Checking for new messages
In-Reply-To: <1199677810.8368.16.camel@infidel>
References: <1199677810.8368.16.camel@infidel>
Message-ID: <alpine.OSX.1.00.0801061950570.18754@pangtzu.panda.com>

On Sun, 6 Jan 2008, Steve Freitas wrote:
> With IMAP4, it seems to be more complicated, but I hope I'm missing
> something here.

IMAP should be easier, MUCH easier, than POP3; UIDs are numeric and 
strictly ascending.  That means that you never need to fetch the map to 
learn about new messages; you can simply fetch <lastuid+1:*>.

> 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.

I suggest that you should use UIDs anyway and ignore the brokenness of 
that server.  Courier is a horrible server, but I suspect that this is a 
problem in that particular installation of Courier.

A server changing UIDVALIDITY has a specific meaning in IMAP: toss out 
everything you remember from before and start anew.  You should NOT 
attempt to overengineer and outsmart the protocol specification, even in 
the face of a broken server.  Otherwise, someone is going to attempt to 
overengineer and outsmart the protocol specification in order to get the 
desired results from your software.

Remember: for every action there is an equal and opposition retaliation!

If you absolutely insist upon not using UIDs,
 	tag FETCH 1:* BODY[HEADER.FIELDS (Message-ID)]
is a semi-reasonable approximation of POP3 UIDs.

Good luck!

-- Mark --

http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.

