This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.
Differences between revisions 22 and 23
Revision 22 as of 2007-03-18 21:39:11
Size: 4167
Editor: TimoSirainen
Comment:
Revision 23 as of 2007-03-18 22:33:45
Size: 4135
Editor: TimoSirainen
Comment:
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:
By default `mail_location` is empty, which means that Dovecot attempts to locate automatically where your mails are. This is done by looking at `~/Maildir`, `/var/mail/username` and `~/mail` in that order. It's usually a good idea to explicitly specify where the mails are, even if the autodetection happens to work. By default `mail_location` setting is empty, which means that Dovecot attempts to locate automatically where your mails are. This is done by looking at `~/Maildir`, `/var/mail/username`, `~/mail` and `~/Mail` in that order. It's usually a good idea to explicitly specify where the mails are, even if the autodetection happens to work.
Line 10: Line 10:
You can use several variables in `mail_location`. A full list of them is in [wiki:Variables Variables], but the most commonly used ones are: You can use several variables in the `mail_location` setting. See ["Variables"] for a full list, but the most commonly used ones are:
Line 15: Line 15:
 * `%h`: Home directory.  * `%h`: Home directory. ~/ works also.
Line 17: Line 17:
Typically with maildir it would be set to: Typically with Maildir it would be set to:
Line 20: Line 20:
mail_location = maildir:%h/Maildir }}} mail_location = maildir:~/Maildir }}}
Line 25: Line 25:
mail_location = mbox:%h/mail:INBOX=/var/mail/%u }}} mail_location = mbox:~/mail:INBOX=/var/mail/%u }}}
Line 34: Line 34:
mail_location = mbox:%h/mail:INBOX=/var/mail/%u:INDEX=%h/indexes }}} mail_location = mbox:~/mail:INBOX=/var/mail/%u:INDEX=~/indexes }}}
Line 40: Line 40:
Having a home directory for users is highly recommended. [wiki:LDA Deliver]'s Sieve plugin already uses the home directory, and it won't work without one. You could even make the home directory be the same as the mail directory, but this isn't necessarily a good idea, especially with mbox storage where the created files would show up as mailboxes. You could instead put the home directory under the mail directory, so that eg. your home directory becomes {{{/var/mail/user/Maildir/home}}} or {{{/var/mail/user/mbox/.imap/home}}}. Having a home directory for users is highly recommended. Dovecot's [:LDA/Sieve:Sieve plugin] already requires a home directory to work, and it probably won't be the last feature to require a home. See "Home directories" in VirtualUsers for more reasons why it's a good idea, and how to give Dovecot a home directory even if you don't have a "real home directory".
Line 42: Line 42:
If you really don't want to set a home directory, you can simply use something like: If you really don't want to set any home directory, you can use something like:
Line 49: Line 49:
It's possible to override mail location for specific users by making the [wiki:UserDatabase user database] return `mail` [wiki:UserDatabase/ExtraFields extra field]. See the [:UserDatabase:user database] page for the specific userdb you're using for more information how to do this. Here are however a couple of examples: It's possible to override the default {{{mail_location}}} for specific users by making the [:UserDatabase:user database] return `mail` [:UserDatabase/ExtraFields:extra field]. See the [:UserDatabase:user database] page for the specific userdb you're using for more information how to do this. Below are however a couple of examples.

Note that %h doesn't work in the userdb queries or templates. ~/ gets expanded later, so use it instead.

Mail location

  • For mbox-specific settings, see ["MailLocation/Mbox"]
  • For Maildir-specific settings, see ["MailLocation/Maildir"]

In configuration file the default mail location is set using mail_location setting. This setting used to be called default_mail_env in Dovecot versions earlier than 1.0.rc11.

By default mail_location setting is empty, which means that Dovecot attempts to locate automatically where your mails are. This is done by looking at ~/Maildir, /var/mail/username, ~/mail and ~/Mail in that order. It's usually a good idea to explicitly specify where the mails are, even if the autodetection happens to work.

You can use several variables in the mail_location setting. See ["Variables"] for a full list, but the most commonly used ones are:

  • %u: Full username.

  • %n: User part in user@domain, same as %u if there's no domain.

  • %d: Domain part in user@domain, empty if there's no domain.

  • %h: Home directory. ~/ works also.

Typically with Maildir it would be set to:

mail_location = maildir:~/Maildir 

or with mbox:

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

Use only absolute paths. Even if relative paths would appear to work, they might just as well break some day.

Index files

Index files are by default stored under the same directory as mails. With maildir they are stored in the actual maildirs, with mbox they are stored under .imap/ directory. You can change these by adding :INDEX=location to location string. For example:

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

If you really want to, you can also disable the index files completely by appending :INDEX=MEMORY.

Homeless users

Having a home directory for users is highly recommended. Dovecot's [:LDA/Sieve:Sieve plugin] already requires a home directory to work, and it probably won't be the last feature to require a home. See "Home directories" in VirtualUsers for more reasons why it's a good idea, and how to give Dovecot a home directory even if you don't have a "real home directory".

If you really don't want to set any home directory, you can use something like:

mail_location = maildir:/home/%u/Maildir 

Per-user mail locations

It's possible to override the default mail_location for specific users by making the [:UserDatabase:user database] return mail [:UserDatabase/ExtraFields:extra field]. See the [:UserDatabase:user database] page for the specific userdb you're using for more information how to do this. Below are however a couple of examples.

Note that %h doesn't work in the userdb queries or templates. ~/ gets expanded later, so use it instead.

SQL

user_query = SELECT home, uid, gid, mail FROM users WHERE user = '%u' 

LDAP

user_attrs = homeDirectory=home,uidNumber=uid,gidNumber=gid,mailLocation=mail 

Passwd-file

user:{PLAIN}password:1000:1000::/home/user::userdb_mail=mbox:~/mail:INBOX=/var/mail/%u 

Mixing mbox and maildir

It's possible to use both mboxes and maildirs for the same user by configuring multiple namespaces. See ["Namespaces"].

Having both mboxes and maildirs mixed within the same namespace isn't currently supported.

Custom mailbox location detection

Dovecot by default detects the mailboxes in this order:

  1. maildir: ~/Maildir
  2. mbox: ~/mail, and /var/mail/%u if it exists
  3. mbox: ~/Mail, and /var/mail/%u if it exists

If you need something else, you can override the mail_executable setting to run a script, which sets the MAIL environment properly. For example:

#/bin/sh

if [ -f $HOME/.maildir ]; then
  export MAIL=maildir:$HOME/.maildir
else
  export MAIL=mbox:$HOME/mail:INBOX=/var/mail/$USER
fi

# Finally execute the imap/pop3. If you use both, you'll need two scripts.
exec /usr/local/libexec/dovecot/imap

NOTE: If you're using namespaces, the MAIL environment is ignored. You'll need to set NAMESPACE_1 (and maybe _2, _3, etc. for each namespace) instead.

None: MailLocation (last edited 2019-09-11 14:05:46 by MichaelSlusarz)