This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.
Differences between revisions 29 and 30
Revision 29 as of 2015-04-30 13:29:05
Size: 3536
Editor: broadband-188-255-26-201
Revision 30 as of 2016-02-07 19:00:29
Size: 3689
Editor: TimoSirainen
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:
  separator = .
Line 35: Line 36:
The inbox setting can be overridden by returning {{{namespace/default/inbox=yes}}} or {{{namespace/default/location=mbox:/var/mail/%u}}} extra field. The separator setting can be overridden by returning {{{namespace/default/separator=.}}} extra field.
Line 44: Line 45:
  '*:storage=100M' as quota_rule, mail_plugins, \
  'gz' as `plugin/zlib_save`
  FROM users WHERE userid = '%u'
  CONCAT('*:bytes=', quota_bytes) AS quota_rule, \
  separator AS "namespace/default/separator" \
  FROM users WHERE username = '%n' and domain = '%d'
Line 53: Line 54:
user_attrs = homeDirectory=home,uidNumber=uid,gidNumber=gid,quotaDovecot=quota,mail_plugins user_attrs = \
  =home=%{ldap:homeDirectory}, \
Line 61: Line 67:
user:{plain}pass:1000:1000::/home/user::userdb_mail=mbox:~/mail userdb_quota_rule=*:storage=100M user:{plain}pass:1000:1000::/home/user::userdb_mail=mbox:~/mail userdb_quota_rule=*:storage=100M userdb_namespace/default/separator=/

User database extra fields

A user database lookup typically returns uid, gid and home fields, as per traditional /etc/passwd lookups. Other fields may also be stored in the userdb, and these are called 'extra fields'. Possibilities are:

  • mail: Mail location, overrides the global mail_location setting.

  • nice: Set the mail process's priority to be the given value.

  • chroot: Chroot to given directory. Overrides mail_chroot setting in dovecot.conf.

  • system_groups_user: Specifies the username whose groups are read from /etc/group (or wherever NSS is configured to taken them from). The logged in user has access to those groups. This may be useful for shared mailboxes.

  • userdb_import: This allows returning multiple extra fields in one TAB-separated field. It's useful for userdbs which are a bit less flexible for returning a variable number of fields (e.g. SQL).

  • uidgid_file: Get uid and gid for user based on the given filename.

  • It's possible to override settings from dovecot.conf (most commonly quota_rule to set per-user quota limits or also plugin-settings).

  • The extra fields are also passed to post-login scripts.

These fields can be returned the exact same way as uid, gid, and home fields. Below are examples for some user databases.

Overriding settings

Most commonly settings are overridden from plugin section. For example if your plugin section has quota=maildir:storage=1024 value and the userdb lookup returns quota=maildir:storage=2048, the original quota setting gets overridden. In fact if the lookup always returns a quota field, there's no point in having the quota setting in plugin section at all, because it always gets overridden anyway.

To understand how imap and pop3 processes see their settings, it may be helpful to know how Dovecot internally passes them:

  1. First all actual settings are first read into memory.
  2. Next if post-login scripting is used, it may modify the settings if wanted.

  3. Last all the extra fields returned by userdb lookup are used to override the settings. Any unknown setting is placed into plugin {} section (e.g. foo=bar will be parsed as if it were plugin { foo=bar }).

If you want to override settings inside sections, you can separate the section name and key with '/'. For example:

namespace default {
  inbox = yes
  separator = .
  location = maildir:~/Maildir

The separator setting can be overridden by returning namespace/default/separator=. extra field.




user_query = SELECT home, uid, gid, \
  CONCAT('*:bytes=', quota_bytes) AS quota_rule, \
  separator AS "namespace/default/separator" \
  FROM users WHERE username = '%n' and domain = '%d'



user_attrs = \
  =home=%{ldap:homeDirectory}, \


Below are examples that show how to give two userdb extra fields ("mail" and "quota"). Note that all userdb extra fields must be prefixed with "userdb_", otherwise they're treated as passdb extra fields.

user:{plain}pass:1000:1000::/home/user::userdb_mail=mbox:~/mail userdb_quota_rule=*:storage=100M userdb_namespace/default/separator=/
user2:{plain}pass2:1001:1001::/home/user2::userdb_mail=maildir:~/Maildir userdb_quota_rule=*:storage=200M

None: UserDatabase/ExtraFields (last edited 2019-09-11 14:07:49 by MichaelSlusarz)