namespace
Default | [None] |
---|---|
Value | Named List Filter |
Creates a new namespace to the list of namespaces. The filter name refers to
the namespace_name
setting.
Example:
namespace foo {
[...]
}
Dovecot supports fully configurable, hierarchical namespaces, which can use different storage drivers.
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.
Dovecot namespaces can be used for several other purposes too:
These different locations and drivers are presented to the client as a single tree.
Each namespace has:
There must be one namespace where the case-insensitive folder named INBOX exists.
All visible namespaces must have the same separator.
Inside each namespace there is a list of folders, which form a sub-hierarchy.
Each folder has a name. In configuration files and log files Dovecot almost always uses the "virtual name", which uses the configured namespace's hierarchy separator as well as the namespace prefix. Depending on the used mailbox_list_layout
setting the internal folder name may be different. The internal name is stored in databases (e.g. mailbox subscriptions), which allows changing the namespace prefix or separator without having to change the databases.
The folder names use UTF-8 character set internally. All folder names must be valid UTF-8. With mailbox_list_layout = fs
and mailbox_list_layout = Maildir++
the folder names are stored in filesystem paths as mUTF-7 (see IMAP RFC 3501) mainly for legacy reasons. This can be changed with the mailbox_list_utf8
setting.
Folder name length restrictions:
The maximum folder name lengths work correctly when folder names aren't stored in filesystem, i.e. mailbox_list_layout = index
is used. Otherwise the OS adds its own limitations to path name lengths and the full 4096 bytes can't be used. With mailbox_list_layout = Maildir++
the path must fit to 254 bytes (due to OS limitations).
A folder can have one or more parent folders that do not physically exist. These are presented with \NoSelect
or \Nonexistent
attribute. It's possible to try to avoid creating these by using the mailbox_list_drop_noselect
setting (enabled by default).
If the Dovecot configuration doesn't explicitly specify a namespace, the inbox namespace is created automatically.
Namespace configuration is defined within a dovecot configuration block with the format:
namespace <name> {
[... namespace settings ...]
}
The namespace name is only used internally within configurations. It allows you to update an existing namespace - by repeating the namespace block and adding additional configuration settings - or allows userdb to override namespace settings for specific users, e.g.:
namespace/name/prefix=foo/
Example configuration for default namespace:
namespace inbox {
separator = .
prefix =
inbox = yes
}
namespace
Default | [None] |
---|---|
Value | Named List Filter |
Creates a new namespace to the list of namespaces. The filter name refers to
the namespace_name
setting.
Example:
namespace foo {
[...]
}
namespace_alias_for
Default | [None] |
---|---|
Value | string |
Refers to an alias namespace's namespace_name
.
If multiple namespaces point to the same location, they should be marked as aliases against one primary namespace. This avoids duplicating work for some commands (listing the same mailbox multiple times).
Mail user variables
can be used.
Note: Alias namespaces often have hidden=yes
and list=no
so
they are not visible unless clients have specifically configured
them, and they're typically used when migrating to a different
namespace prefix for existing users.
Example:
namespace inbox {
prefix =
# ...
}
namespace alias {
prefix = INBOX/
alias_for = inbox
}
namespace_disabled
Default | no |
---|---|
Value | boolean |
If yes
, namespace is disabled and cannot be accessed by user in any way.
Useful when returned by a userdb lookup to easily configure per-user namespaces.
namespace_hidden
Default | no |
---|---|
Value | boolean |
If yes
, namespace will be hidden from IMAP NAMESPACE (RFC 2342)
command.
namespace_ignore_on_failure
Default | no |
---|---|
Value | boolean |
If namespace's storage initialization fails, by default the entire session will fail to start. If this is set, this namespace will be ignored instead.
namespace_inbox
Default | no |
---|---|
Value | boolean |
If yes
, this namespace will be considered the one holding the INBOX
folder.
There can be only one namespace defined like this.
namespace_list
Default | yes |
---|---|
Value | string |
Allowed Values | yes no children |
See Also |
Include this namespace in LIST output when listing its parent's folders.
Options:
Value | Description |
---|---|
children |
Namespace prefix list listed only if it has child mailboxes. |
no |
Namespace and mailboxes not listed unless listing requests explicitly mailboxes under the namespace prefix. |
yes |
Namespace and mailboxes are always listed. |
It is still possible to list the namespace's folders by explicitly asking
for them. For example, if this setting is no
, using LIST "" *
with
namespace prefix "lazy-expunge/" won't list it, but using LIST "" lazy-expunge/*
lists all folders under it.
namespace_name
Default | [None] |
---|---|
Value | string |
Name of the namespace. This is used only in configurations - it's not visible
to user. The namespace
filter refers to this setting.
namespace_order
Default | [None] |
---|---|
Value | unsigned integer |
Sets display order in IMAP NAMESPACE (RFC 2342) command.
Namespaces are automatically numbered if this setting does not exist.
namespace_prefix
Default | [None] |
---|---|
Value | string |
Specifies prefix for namespace.
INFO
Must end with namespace_separator
.
Mail user variables
can be used.
Example:
namespace {
prefix = Shared/
separator = /
}
namespace_separator
Default | "." for Maildir; "/" for other mbox formats |
---|---|
Value | string |
See Also |
Specifies the hierarchy separator for the namespace.
The separator is a single character, which can't then otherwise be used in folder names.
The commonly used separators are .
and /
, but other separators can
be used as well. For example ^
is less likely to be found in normal
folder names.
Recommended value is to leave it empty and accept the default value.
namespace_subscriptions
Default | yes |
---|---|
Value | boolean |
Whether subscriptions are stored in this namespace.
This is usually no
for shared namespaces so that the shared folders'
subscriptions are stored in the user's primary subscriptions file. If
no
, the subscriptions are stored in the first parent namespace (based
on the prefix) that has this setting enabled.
Example: If this setting is no
for a namespace with
prefix=foo/bar/
, Dovecot first sees if there's a prefix=foo/
namespace with subscriptions=yes
and then a namespace with an empty
prefix. If neither is found, an error is given.
namespace_type
Default | private |
---|---|
Value | string |
Allowed Values | private shared public |
The namespace type. One of:
Type | Description |
---|---|
public |
Contains public shared mailboxes. |
private |
Typically contains only user's own private mailboxes. |
shared |
Contains other users' user shared mailboxes. |
namespace_separator
specifies the character that is used to separate the parent mailbox from its child mailbox.
For example if you have a mailbox "foo" with child mailbox "bar", the full path to the child mailbox would be "foo/bar" with /
as the separator, and "foo.bar" with .
as the separator.
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".
Example:
mailbox_list_layout | Layout Separator | Namespace Separator | Mailbox Name | Directory |
---|---|---|---|---|
Maildir++ (default) | . | . | foo.bar | ~/Maildir/.foo.bar/ |
Maildir++ (default) | . | / | foo/bar | ~/Maildir/.foo.bar/ |
fs | / | . | foo.bar | ~/Maildir/foo/bar/ |
fs | / | / | foo/bar | ~/Maildir/foo/bar/ |
TIP
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 mailbox_list_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
.
A commonly used separator is /
. It probably causes the least amount of trouble with different IMAP clients. The ^
separator is troublesome with Thunderbird. If \
has to be used, it needs to be escaped in configuration:
namespace {
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.
To change namespace settings from userdb, you need to return namespace/<name>/setting+=value
.
To create a namespace, make sure you first return namespace+=<name>[,<name>,...]
and settings after this.
This adds a new given namespace. Without +
all the namespaces are replaced with the given list.
userdb static {
fields {
namespace += special
namespace/special/mail_path = /var/special/%{user}
namespace/special/prefix = special/
}
}
See shared mailboxes.
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/"
mail_driver = mbox
mail_path = ~/mail
mail_index_path = /var/mail/%{user}
inbox = yes
hidden = yes
list = no
}
namespace {
separator = /
prefix =
mail_driver = maildir
mail_path = ~/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), i.e. like a directory. So specifically with inbox = yes
, having list = no
is often desirable.
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 = inbox
}
namespace compat2 {
separator = /
prefix = ~/mail/
hidden = yes
list = no
alias_for = inbox
}
namespace compat3 {
separator = /
prefix = ~%{user}/mail/
hidden = yes
list = no
alias_for = inbox
}
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 = inbox
}
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 issues:
LIST INBOX.*
, they may still do LSUB *
, resulting in mixed results.See also migrating mailboxes
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:
userdb sql {
query = SELECT Location as 'namespace/docs/mail_path' \
FROM Namespaces \
WHERE ..
}
If you follow some advice to separate your "INBOX", "shared/" and "public/" namespaces by choosing "INBOX/" as your prefix for the inboxes you will see, that you run into troubles with subscriptions. Thats, because there is no parent namespace for "shared/" and "public/" if you set subscriptions = no
for those namespaces.
If you set subscriptions = yes
for "shared/" and "public/" you will see yourself in the situation, that all users share the same subscription files under the location of those mailboxes.
One good solution is, to create a so called "hidden subscription namespace" with subscriptions turned on and setting subscriptions = no
for the other namespaces:
namespace subscriptions {
subscriptions = yes
prefix = ""
list = no
hidden = yes
}
namespace inbox {
inbox = yes
subscriptions = no
prefix = INBOX/
separator = /
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Spam {
auto = subscribe
special_use = \Junk
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
}
namespace {
type = shared
prefix = shared/$user/
mail_driver = mdbox
mail_path = %{owner_home}/mdbox
mail_index_private_path = %{owner_home}/mdbox/shared
list = children
subscriptions = no
}
namespace {
type = public
separator = /
prefix = public/
mail_driver = mdbox
mail_path = /usr/local/mail/public/mdbox
mail_index_private_path = ~/mdbox/public
subscriptions = no
list = children
}
Mailbox configuration is typically defined inside a namespace
block so it only applies to the specific namespace.
mailbox
Default | [None] |
---|---|
Value | Named List Filter |
Create a new mailbox to the list of mailboxes. The filter name refers to the
mailbox_name
setting.
TIP
If the mailbox name has spaces, you can put it into quotes:
mailbox "Test Mailbox" {
# ...
}
mailbox_auto
Default | no |
---|---|
Value | string |
Allowed Values | create no subscribe |
Autocreate and/or subscribe to the mailbox?
Value | Description |
---|---|
create |
Autocreate but don't autosubscribe |
no |
Don't autocreate or autosubscribe |
subscribe |
Autocreate and autosubscribe |
Autocreated mailboxes are created lazily to disk only when accessed for the first time. The autosubscribed mailboxes aren't written to subscriptions file, unless SUBSCRIBE command is explicitly used for them.
mailbox_autoexpunge
Default | [None] |
---|---|
Value | time |
See Also |
Expunge all mails in this mailbox whose saved-timestamp is older than this value.
For IMAP and POP3 this happens after the client is already disconnected.
For LMTP this happens when the user's mail delivery is finished. Note that in case there are multiple recipients, autoexpunging is done only for some of the recipients to prevent delays with the mail delivery: The last recipient user is autoexpunged first. Next, the first recipient user is autoexpunged (because the first user's mail was kept open in case it could be directly copied to the other users). None of the middle recipient users are autoexpunged.
mailbox_list_index = yes
is highly recommended when
using this setting, as it avoids actually opening the mailbox to see if
anything needs to be expunged.
mail_always_cache_fields = date.save
is also
recommended when using this setting with sdbox or Maildir,
as it avoids using stat()
to find out the mail's saved-timestamp. With
mdbox format this isn't necessary, since the saved-timestamp is
always available.
mailbox_autoexpunge_max_mails
Default | [None] |
---|---|
Value | unsigned integer |
Mails are autoexpunged until mail count is at or below this number of messages.
Once this threshold has been reached, mailbox_autoexpunge
processing is done.
mailbox_name
Default | [None] |
---|---|
Value | string |
Name of the mailbox being configured. The mailbox
filter name
refers to this setting.
mailbox_special_use
Default | [None] |
---|---|
Value | Boolean List |
Changes |
|
List of SPECIAL-USE (RFC 6154) flags to broadcast for the mailbox.
There are no validity checks, so you could specify anything you want here, but it's not a good idea to use other than the standard ones specified in the RFC.
namespace inbox {
# the namespace prefix isn't added again to the mailbox names.
#prefix = INBOX.
inbox = yes
# ...
mailbox Trash {
auto = no
special_use = \Trash
}
mailbox Drafts {
auto = no
special_use = \Drafts
}
mailbox Sent {
auto = subscribe # autocreate and autosubscribe the Sent mailbox
special_use = \Sent
}
mailbox "Sent Messages" {
auto = no
special_use = \Sent
}
mailbox Spam {
auto = create # autocreate Spam, but don't autosubscribe
special_use = \Junk
}
mailbox virtual/All { # if you have a virtual "All messages" mailbox
auto = no
special_use = \All
}
}