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

Multiple Authentication Databases

Dovecot 1.0-tests support defining multiple authentication databases, so that if password doesn't match in the first database, it checks the next one. This can be useful if you want to easily support having both local system users in /etc/passwd but also virtual users. This isn't possible in 0.99 releases.

Currently the fallbacking works only with PLAIN authentication mechanism.

This can be configured in the following way:

auth local {
  mechanisms = plain
  userdb = passwd
  passdb = pam
  user = root
}

auth virtual {
  mechanisms = plain
  userdb = pgsql /etc/dovecot-pgsql.conf
  passdb = pgsql /etc/dovecot-pgsql.conf
  user = dovecot-auth
}

You should make sure that the same user doesn't exist in multiple password databases. The order in which the authentications are done isn't guaranteed.