[Imap-protocol] Where to start?

Robert Mueller robm at fastmail.fm
Sun Jun 5 17:20:59 PDT 2011

> > 4). Decide what data to keep in memory for each message in an open

> > mailbox. (By "open", I mean one for which a session is in

> > progress, that is opened as the result of a SELECT or EXAMINE

> > command.) A likely minimum would be UID, IMAP message flags,

> > message size and, of course, a reference to the message itself. I

> > am assuming that this information is indexed by message number and

> > hence that that is not explicitly stored. You may find reason to

> > add more data such as a flag indicating if the message is matched

> > in a current SEARCH.

One thing that can be tricky if you don't design it in up front is the
way you end up with multiple message list views if you have multiple
clients connected.

5.5. Multiple Commands in Progress
A non-obvious ambiguity occurs with commands that permit an untagged
EXPUNGE response (commands other than FETCH, STORE, and SEARCH),
since an untagged EXPUNGE response can invalidate sequence numbers in
a subsequent command. This is not a problem for FETCH, STORE, or
SEARCH commands because servers are prohibited from sending EXPUNGE
responses while any of those commands are in progress.

So one client might delete + expunge a message, but another connection
won't see that expunge until they do a command that allows it to be
seen. This can significantly affect how you design your internal state
management, namely that when you expunge a message, you probably just
want to mark it as expunged on disk and actually cleanup later, rather
than removing it immediately from your mailbox state. This is useful
longer term for things like QRESYNC as well.

I'm sure Bron (cc'd) can make some comments on this as well, given the
significant changes he made to cyrus to make this work correctly.


More information about the Imap-protocol mailing list