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

mbox configuration

See MailboxFormat/mbox for a complete description of how Dovecot has implemented mbox support.

Mail location

In many systems the user's mails are by default stored in /var/mail/username file. This file is called INBOX in IMAP world. Since IMAP supports multiple mailboxes, you'll need to have a directory for them as well. Usually ~/mail is a good choice for this. For installation such as this, the mail location is specified with:

# %u is replaced with the username that logs in
mail_location = mbox:~/mail:INBOX=/var/mail/%u

It's in no way a requirement to have the INBOX in /var/mail/ directory. In fact this often just brings problems because Dovecot might not be able to write dotlock files to the directory (see below). You can avoid this completely by just keeping everything in ~/mail/:

# INBOX exists in ~/mail/inbox
mail_location = mbox:~/mail

Index files

See MailLocation#indexfiles for full explanation of how to change the index path. For example:

mail_location = mbox:~/mail:INBOX=/var/mail/%u:INDEX=/var/indexes/%u


Make sure that all software accessing the mboxes are using the same locking methods in the same order. The order is important to prevent deadlocking. From Dovecot's side you can change these from mbox_read_locks and mbox_write_locks settings. See MboxLocking for more information.

/var/mail/ dotlocks

Often mbox write locks include dotlock, which means that Dovecot needs to create a new "<mbox>.lock" file to the directory where the mbox file exists. If your INBOXes are in /var/mail/ directory you may have to give Dovecot write access to the directory. There are two ways the /var/mail/ directory's permissions have traditionally been set up:

You can give Dovecot access to mail group by setting:

mail_privileged_group = mail

NOTE: With LDA the mail_privileged_group setting unfortunately doesn't work, so you'll have to use the sticky bit, disable dotlocking completely or use LMTP server instead.

/var/mail/* permissions

In some systems the /var/mail/$USER files have 0660 mode permissions. This causes Dovecot to try to preserve the file's group, and if it doesn't have permissions to do so, it'll fail with an error:

imap(user): Error: chown(/home/user/mail/.imap/INBOX, -1, 12(mail)) failed: Operation not permitted (egid=1000(user), group based on /var/mail/user)

There is rarely any real need for the files to have 0660 mode, so the best solution for this problem is to just change the mode to 0600:

chmod 0600 /var/mail/*


The settings below are related to mbox performance. See MailboxFormat/mbox for more complete description of what they do.

Only /var/mail/ mboxes

With POP3 it's been traditional that users have their mails only in the /var/mail/ directory. IMAP however supports having multiple mailboxes, so each user has to have a private directory where the mailboxes are stored. Dovecot also needs a directory for its index files unless you disable them completely.

If you really want to use Dovecot as a plain POP3 server without index files, you can work around the problem of not having the per-user directory:

Directory layout

By default Dovecot uses filesystem layout under mbox. This means that mail is stored in mbox files under hierarchical directories, for example:

One upshot of this is that it is not normally possible to have mailboxes which are subfolders of mailboxes containing messages.

As an alternative, it is possible to configure Dovecot to store all mailboxes in a single directory with hierarchical levels separated by a dot. This can be configured by adding :LAYOUT=maildir++ to the mail location. There are, however, some further considerations when doing this; see MboxChildFolders for some examples.

Control files

Under mbox format, Dovecot maintains the subscribed mailboxes list in a file .subscriptions which by default is stored in the mail location root. So in the example configuration this would be at ~/mail/.subscriptions.

If you want to put this somewhere else, you can change the directory in which the .subscriptions file is kept by using the CONTROL parameter. So for example, if we configured the mail location using:

mail_location = mbox:~/mail:CONTROL=~/mail-control

then the subscribed mailboxes list would be maintained at ~/mail-control/.subscriptions.

One practical application of the CONTROL parameter is described at MboxChildFolders.

Message file name

By default, Dovecot stores messages for INBOX in an mbox file called "inbox", and messages for all other mailboxes in an mbox file whose relative path is equivalent to the name of the mailbox. Under this scheme, it is not possible to have mailboxes which contain both messages and child mailboxes.

However, the behaviour (for mailboxes other than INBOX) can be changed using the DIRNAME parameter. If the DIRNAME parameter is specified with a particular value, then Dovecot will store messages in a file with a name of that value, in a directory with a name equivalent to the mailbox name.

There are, however, some further considerations when doing this; see MboxChildFolders for an example.

None: MailLocation/mbox (last edited 2012-07-25 21:11:09 by TimoSirainen)