I was having a problem in which I wanted to have email addresses with the same name but different domains, such as firstname.lastname@example.org and email@example.com. 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=%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@domain:hash, and then it all worked.