User authentication in Dovecot/Postfix with user@domain

Published on 15th Jan, 2018 by David Young

I was having a problem in which I wanted to have email addresses with the same name but different domains, such as user@example.com and user@example.net. Unfortunately Dovecot was stripping off the domain before checking the passwd file, which was less than ideal. The solution was in /etc/dovecot/conf.d/auth-passwdfile.conf.ext in the args for the passdb config. Changing username_format=%n to username_format=%u had the effect of asking dovecot to look the entire supplied username up in the passwd file, rather than just the user part. Of course I then had to edit all of the passwd file entries from user:hash to user@domain:hash, and then it all worked.