[Imap-protocol] Namespace questions

Mark Crispin mrc+imap at panda.com
Wed May 19 09:16:41 PDT 2010


On Wed, 19 May 2010, Pete Maclean wrote:

> I am adding support for namespaces to my IMAP server and have some

> questions about how the LIST command should work with them.


It's a difficult topic. The best way to understand it is that there may
be multiple independent mail stores, of which only one are the "user's
mailboxes". Consider, for example, an IMAP server that exports netnews
groups.

An analog that you might understand are drive letters in Windows. It's
not completely the same, but some of the semantics are similar enough that
the IMAP rules may make sense if you keep those in mind.


> My main difficulty stems from the fact that LIST is described

> as returning "names" and I am unclear as to just what a "name" can be.


This refers to a name in the hierarchy, some or all of which are
mailboxes. There may also be hierarchical names that are mere
directories; that contain other names but are not a mailbox themselves.
Consider that in netnews "comp.mail.imap" is a mailbox but "comp" and
"comp.mail" are not.


> Is it correct that the command:

>

> 1 LIST "" *

>

> should list mailboxes in all namespaces?


NO!!!

This command lists the mailboxes in the default namespace, which in most
implementations is the user's private set of mailboxes.


> Should it include namespace prefixes by

> themselves?


NO!!! That completely obliviates the purpose and use of namespaces.


> What about:

>

> 1 LIST "" %

>

> My guess is that this should list top-level mailboxes in the default

> namespace


Yes.


> and the prefixes of other namespaces.


NO!!!


> (My notion of

> "default namespace" is simply the namespace that does not have a prefix.)


Correct.


> If I am correct about these first two commands then, as far as I can

> see, there is no way in a single LIST command to list only those

> mailboxes in the default namespace -- which seems unfortunate. Is

> this the case?


No, it's not. The LIST command lists mailboxes in one namespace. If
there isn't a namespace somewhere in the reference or pattern argument,
then LIST will list only the default namespace.


> C: 4 NAMESPACE

> S: * NAMESPACE (("#Namespace1" "/")("#Namespace2" "/")("" "/")) NIL NIL

> S: 4 OK NAMESPACE completed


The response should be:

S: * NAMESPACE (("#Namespace1/" "/")("#Namespace2/" "/")("" "/")) NIL NIL

Otherwise, the only two mailboxes in those namespaces are #Namespace1 and
#Namespace2.

Worse, with this response, #Namespace1 is the default namespace (and thus
the only mailbox is #Namespace1). So you probably wanted:

S: * NAMESPACE (("" "/"))("#Namespace1/" "/")("#Namespace2/" "/") NIL NIL


> C: 6 LIST "" #Namespace1

> S: 6 OK LIST completed


So, #Namespace1 can only have one mailbox ("#Namespace1") because there's
no terminating hierarchy delimiter in the NAMESPACE result, but that name
doesn't exist.

Now, if the NAMESPACE result had "#Namespace1/", then you could have done

C: 6 LIST "" #Namespace1/*

and maybe you would see some names in there.


> For one thing, I am unsure as to whether my server's response to this

> LIST command should be as shown or like this:

>

> C: 6 LIST "" #Namespace1

> S: * LIST (\Noselect) "/" #Namespace1

> S: 6 OK LIST completed


Typically, a namespace is not a hierarchical name itself, but rather the
identifier for a hierarchy. So usually, there is no \NoSelect response
for the namespace itself. IMAP does not specifically forbid it though.

Now,

6 LIST "" #Namespace1/

is an entirely different matter, since the root of the namespace may be
something reasonable to list.

And, certainly

6 LIST "" #Namespace1/*

and

6 LIST "" #Namespace1/%

are quite reasonable and common.

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



More information about the Imap-protocol mailing list