This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.

Namespaces

Dovecot supports fully configurable namespaces. Their original and primary purpose is to provide Namespace IMAP extension (RFC 2342) support, which allows giving IMAP clients hints about where to locate mailboxes and whether they're private, shared or public. Unfortunately most IMAP clients don't support this extension.

Dovecot namespaces can be used for several other purposes too:

Configuration

In v2.1+ there's a default inbox namespace added in 10-mail.conf. If the configuration doesn't explicitly specify a namespace (as was in v2.0 and older) a default namespace is created automatically.

The section name in namespaces (e.g. namespace sectionname { .. }  is used only internally within configuration. It's not required at all, but it allows you to update an existing namespace (like how 15-mailboxes.conf does) or have userdb override namespace settings for specific users (namespace/sectionname/prefix=foo/).

Namespace types

There are 3 types of namespaces:

Hierarchy separators

Hierarchy separator specifies the character that is used to separate a parent mailbox from its child mailbox. For example if you have a mailbox "foo" with a child mailbox "bar", the full path to the child mailbox would be "foo/bar" if the separator was '/'. With a separator '.' it would be "foo.bar".

IMAP clients, Sieve scripts and many parts of Dovecot configuration use the configured separator when referring to mailboxes. This means that if you change the separator, you may break things.

However, changing the separator doesn't change the on-disk "layout separator". For example:

mail_location

Layout sep

NS sep

Mailbox name

Directory

maildir:~/Maildir

.

.

foo.bar

~/Maildir/.foo.bar/

maildir:~/Maildir

.

/

foo/bar

~/Maildir/.foo.bar/

maildir:~/Maildir:LAYOUT=fs

/

.

foo.bar

~/Maildir/foo/bar/

maildir:~/Maildir:LAYOUT=fs

/

/

foo/bar

~/Maildir/foo/bar/

Note how the "namespace separator" changes only the "Mailbox name", but doesn't change the directory where the mails are stored. The "layout separator" can only be changed by changing the LAYOUT, which also affects the entire directory structure.

The layout separator also restricts the mailbox names. For example if the layout separator is '.', you can't just set separator to '/' and create a mailbox named "foo.bar". If you need to do this, you can use listescape plugin to add escape the mailbox names as necessary.

A commonly used separator is '/'. It probably causes the least amount of trouble with different IMAP clients. '^' separator is troublesome with Thunderbird. When '\' should be used it must be quoted, so one sets separator = "\\"

You should use the same hierarchy separator for all namespaces. All list=yes namespaces must use the same separator, but if you find it necessary (e.g. for backwards compatibility namespaces) you may use different separators for list=no namespaces.

Namespace settings

Shared Mailboxes

See SharedMailboxes.

Examples

Mixed mbox and Maildir

If you have your INBOX as mbox in /var/mail/username and the rest of the mailboxes in Maildir format under ~/Maildir, you can do this by creating two namespaces:

namespace {
  separator = /
  prefix = "#mbox/"
  location = mbox:~/mail:INBOX=/var/mail/%u
  inbox = yes
  hidden = yes
  list = no
}
namespace {
  separator = /
  prefix =
  location = maildir:~/Maildir
}

Without the list = no setting in the first namespace, clients would see the "#mbox" namespace as a non-selectable mailbox named "#mbox" but with child mailboxes (the mbox files in the ~/mail directory), ie. like a directory. So specifically with inbox = yes, having list = no is often desirable.

Backwards Compatibility: UW-IMAP

When switching from UW-IMAP and you don't want to give users full access to filesystem, you can create hidden namespaces which allow users to access their mails using their existing namespace settings in clients.

# default namespace
namespace inbox {
  separator = /
  prefix =
  inbox = yes
}
# for backwards compatibility:
namespace compat1 {
  separator = /
  prefix = mail/
  hidden = yes
  list = no
  alias_for =
}
namespace compat2 {
  separator = /
  prefix = ~/mail/
  hidden = yes
  list = no
  alias_for =
}
namespace compat3 {
  separator = /
  prefix = ~%u/mail/
  hidden = yes
  list = no
  alias_for =
}

Backwards Compatibility: Courier IMAP

Recommended: You can continue using the same INBOX. namespace as Courier:

namespace inbox {
  separator = .
  prefix = INBOX.
  inbox = yes
}

Alternatively: Create the INBOX. as a compatibility name, so old clients can continue using it while new clients will use the empty prefix namespace:

namespace inbox {
  separator = /
  prefix =
  inbox = yes
}

namespace compat {
  separator = .
  prefix = INBOX.
  inbox = no
  hidden = yes
  list = no
  alias_for =
}

The "separator=/" allows the INBOX to have child mailboxes. Otherwise with "separator=." it wouldn't be possible to know if "INBOX.foo" means INBOX's "foo" child or the root "foo" mailbox in "INBOX." compatibility namespace. With "separator=/" the difference is clear with "INBOX/foo" vs. "INBOX.foo".

The alternative configuration is not recommended, as it may introduce there problems:

Per-user Namespace Location From SQL

You need to give the namespace a name, for example "docs" below:

namespace docs {
  type = public
  separator = /
  prefix = Public/
}

Then you have an SQL table like:

CREATE TABLE Namespaces (
..
  Location varchar(255) NOT NULL,
..
)

Now if you want to set the namespace location from the Namespaces table, use something like:

user_query = SELECT Location as 'namespace/docs/location' FROM Namespaces WHERE ..

Namespaces (last edited 2013-11-13 13:43:30 by 84)