This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.
Differences between revisions 7 and 8
Revision 7 as of 2005-10-01 09:51:06
Size: 3045
Editor: TimoSirainen
Comment:
Revision 8 as of 2006-11-05 14:40:55
Size: 3652
Editor: TimoSirainen
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
In configuration file the default mail location is set using `default_mail_env` setting. 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.
Line 5: Line 5:
You can use some variables in the value: You can use several variables in the value. A full list of them is in [wiki:Variables Variables], but the most commonly used are:
Line 7: Line 7:
 * %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

In 1
.0-test versions there are more, see [wiki:Variables Variables].
 * `%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.
Line 17: Line 15:
default_mail_env = maildir:%h/Maildir
}}}
default_mail_env = maildir:%h/Maildir }}}
Line 23: Line 20:
default_mail_env = mbox:%h/mail:INBOX=/var/mail/%u
}}}
default_mail_env = mbox:%h/mail:INBOX=/var/mail/%u }}}

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

== Index files ==
Line 29: Line 29:
default_mail_env = mbox:%h/mail:INBOX=/var/mail/%u:INDEX=%h/indexes
}}}
default_mail_env = mbox:%h/mail:INBOX=/var/mail/%u:INDEX=%h/indexes }}}
Line 32: Line 31:
If you didn't set home directory, %h can't be used. Instead you can do something like: == Homeless users ==

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 where the created files would show up as mailboxes. If your home and mail directories are the same, you could use:
Line 35: Line 36:
default_mail_env = maildir:/home/%u/Maildir
}}}
default_mail_env = maildir:%h }}}
Line 38: Line 38:
With virtual users the mail and home directories are probably the same. In that case you would just do: If you really don't want to set a home directory, you can simply use something like:
Line 41: Line 41:
default_mail_env = maildir:%h
}}}
default_mail_env = maildir:/home/%u/Maildir }}}
Line 44: Line 43:
= Per-user mail locations = == Per-user mail locations ==
Line 46: Line 45:
It's possible to override `default_mail_env` for specific users in authentication userdb. It's possible to override `mail_executable` for specific users by making the [wiki:UserDatabase user database] return `mail` [wiki:UserDatabase/ExtraFields extra fields]. See your specific user database page for more information how to do this. Here are however a couple of examples:
Line 48: Line 47:
== SQL ==

Return `mail` field in `user_query`, for example:
=== SQL ===
Line 53: Line 50:
user_query = SELECT home, uid, gid, mail FROM users WHERE user = '%u'
}}}
user_query = SELECT home, uid, gid, mail FROM users WHERE user = '%u' }}}
Line 56: Line 52:
== LDAP ==

Specify mail attribute in `user_attrs`, for example:
=== LDAP ===
Line 61: Line 55:
user_attrs = uid,homeDirectory,mailLocation,,uidNumber,gidNumber
}}}
user_attrs = homeDirectory=home,uidNumber=uid,gidNumber=gid,mailLocation=mail }}}
Line 64: Line 57:
== passwd-file ==

The mail attribute is set as last field in passwd-file, for example:
=== Passwd-file ===
Line 69: Line 60:
user:{PLAIN}password:1000:1000::/home/user:/bin/false::mbox:%h/mail:INBOX=/var/mail/%u
}}}
user:{PLAIN}password:1000:1000::/home/user::userdb_mail=mbox:%h/mail:INBOX=/var/mail/%u }}}
Line 72: Line 62:
= Mixing mbox and maildir = == Mixing mbox and maildir ==
Line 74: Line 64:
With 1.0-tests it's possible to use both mboxes and maildirs for same user with namespaces. See [wiki:Namespaces Namespaces]. It's possible to use both mboxes and maildirs for the same user with namespaces. See [wiki:Namespaces Namespaces].
Line 76: Line 66:
Having mixed mbox/maildirs within same namespace isn't currently supported. Having both mboxes and maildirs mixed within the same namespace isn't currently supported.
Line 78: Line 68:
= Only /var/mail mboxes = == Only /var/mail mboxes ==

Mail location

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.

You can use several variables in the value. A full list of them is in [wiki:Variables Variables], but the most commonly used 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.

Typically with maildir this would be set to:

default_mail_env = maildir:%h/Maildir 

or with mbox:

default_mail_env = mbox:%h/mail:INBOX=/var/mail/%u 

Use only absolute paths. Even if relative paths might appear to work, they could 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:

default_mail_env = mbox:%h/mail:INBOX=/var/mail/%u:INDEX=%h/indexes 

Homeless users

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 where the created files would show up as mailboxes. If your home and mail directories are the same, you could use:

default_mail_env = maildir:%h 

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

default_mail_env = maildir:/home/%u/Maildir 

Per-user mail locations

It's possible to override mail_executable for specific users by making the [wiki:UserDatabase user database] return mail [wiki:UserDatabase/ExtraFields extra fields]. See your specific user database page for more information how to do this. Here are however a couple of examples:

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:%h/mail:INBOX=/var/mail/%u 

Mixing mbox and maildir

It's possible to use both mboxes and maildirs for the same user with namespaces. See [wiki:Namespaces Namespaces].

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

Only /var/mail mboxes

With POP3 it's been traditional that users have their mails only in /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 indexes 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:

  • Set users' home directory to /tmp in userdb

  • Modify default_mail_env setting so that the mail root directory is also /tmp and append :INDEX=MEMORY to it. For example: default_mail_env = mbox:/tmp:INBOX=/var/mail/%u:INDEX=MEMORY

  • Make sure that the users don't have IMAP access, or they can start writing to /tmp and accidentally share mail with others users

Instead of /tmp directory you can use some other non-writable directory which could be safer.

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