Subject: multi-client-safe new message checking - best practices?

From: Bill McCoy <[email-masked]>
Date: Fri, 21 Mar 2003 11:54:38 -0800

I have implemented a script for weblog-style presentation of IMAP message
folders, intended to provide a seamless means for IMAP users to publish and
manage weblog entries within their email clients, using IMAP as the content
database and supporting image content seamlessly through MIME attachements.
A working example is http://www.offback.com/IMPblog . I'm using PHP and the
built-in PHP IMAP library, which is built on the UW C client library, has
pretty effectively insulated me from worrying about the IMAP protocol other
than a bit of Mullet&Mullet and FAQ reading. As I'm preparing to release its
source I've been working on scalability, and have hit a stumbling block.

The PHP IMAP API function "imap_check" purports to return a date
representing the "last change of mailbox contents" which seemed like just
the ticket for an efficient new message check. Since I'm presenting content
which is likely to change relatively slowly relative, vs. a users inbox or a
bulletin board, and since there will be by definition other IMAP client(s)
manipulating this content, having to repetitively re-acquire all the mailbox
content is burdensome, especially since with certain IMAP servers over
non-local network connections it appears that this can be a multi-second
process, resulting in a noticeable delay. I have implemented timestamp-based
page caching but with an infrequently visited site most visitors would still
experience the full delay unless the timeout is extremely long, which would
defeat the purpose of having a weblog rendition which transparently matches
the current IMAP server state.

However, imap_check has been known for some time to be buggily implemented
and just returns the current time, as described here:
http://php.lamphost.net/manual/en/function.imap-check.php - the bug is
logged but not fixed or even responded to in on any of the PHP discussion
lists.

I assumed that I would just find another way to implement the functionality
myself as a workaround (and potentially a PHP bug fix submission). However,
the IMAP client FAQ info I have found didn't really tell me how to check for
new mail in a multi-client-safe way, which also works with posts that have
been moved or copied from other folders. Threads like
http://www.washington.edu/imap/listarch/1999/msg00008.html have me unsure of
how to proceed, especially since the discusssions on this seem to be several
years old.

If anyone can advise on the current best way to efficiently implement
"what's the date of the most recent change to this mailbox?", or provide a
pointer to information on this, I would appreciate an email reply. Once
again for my purposes it's critical that this be a multi-client-safe way and
portable across IMAP servers. And, that it work reliably in the face of
message copying/moving between folders.

Thanks in advance.

--Bill McCoy
[email-masked]

P.S. off topic, but if anyone has any thoughts on the IMAP message folder
<-> weblog mapping, or pointers to other work in this area, I'd love to hear
them.
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------