[imapfilter-devel] IMAPFilter 2.1

William Faulk wfaulk at cortina-systems.com
Tue Nov 24 18:13:32 EET 2009


On 11/24/2009 03:12 AM, Lefteris Chatzimparmpas wrote:
>
> I believe in the notifications sent from the server, you don't get which
> messages have arrived, but only the number of them (eg. "12 EXISTS", "1
> RECENT", "2 EXPUNGE", etc.), but maybe some servers return more detailed
> untagged responses, though I haven't seen any myself.

If you get "12 EXISTS", that means that the folder now contains 12 
messages, which, by definition, are messages 1 through 12.  Assuming 
that you know how many existed before and you follow IDLE's EXISTSes and 
EXPUNGEs (or, more precisely, the most recent EXIST and any subsequent 
EXPUNGEs), you know which messages arrived.  You don't have the UID, but 
that's easily obtainable from the message number, if you need it.

> What you could do after you get a successful return from IDLE is a
> search with for example is_new(), which will give you all the newly
> arrived messages.

Actually, is_recent() would do what I'm looking for.  When I initially 
started using imapfilter, I was doing testing without using 
become_daemon(), and neither is_new() or is_recent() would find the 
right messages, assuming that there's another IMAP client running, as 
new messages would be set as recent for it, and not for any subsequent 
clients.

However, if I had rethought this after activating become_daemon(), I 
would have found that is_recent() would have worked properly.

Actually, the RFC says that "[i]f multiple connections have the same 
mailbox selected simultaneously, it is undefined which of these 
connections will see newly-arrive[d] messages with \Recent set and which 
will see it without \Recent set."  So, there's no universal way to 
assume that \Recent will work without knowing that there's no other IMAP 
client connected, other than knowing the quirks of the IMAP server being 
used.

That said, my current IMAP server (sadly, Exchange) happens to set 
\Recent for all connected clients, so is_recent() should work for me, 
but not necessarily in all cases.  (Unless there's a protocol update I'm 
not aware of that changes that clause of how \Recent works.)

 > I can add in the returned arguments the untagged responses, but I
 > believe it won't be very useful, based on what you expected.

Consider my arguments above and do what you think sounds right.

-Bitt


More information about the Imapfilter-devel mailing list