On 26/08/25, Alex (mysqlstudent@gmail.com) wrote:
If you only have a single domain name, this should work. The method I am using allows a larger scope. You can loging as user1 or user1@domain1, etc.
If a user provides just "username" I run a query that tries to match it against domain1, domain, 2, domainM. Whichever matches first is used.
I guess it might be a good idea to force a bare username to have a made up domain, such as example.com, to avoid the case where tom matches a tom in another domain and guesses pass123 is their password.
I've tried to consider that situation in this example: https://github.com/rorycl/dovecot-config/tree/main/two-userdbs
In SQL I guess that might mean doing something like running a query like
domain IN (${user|domain}, 'example.com')
, and ensuring all domain-less users are given that default domain in the users table.This looks like an interesting solution. I'm unsure how your two-userdbs code would make this work, though? Do you have specific instructions on how I might be able to do this?
Odhiambo, I'm also interested in your offer from above. Are you able to send me the code/ideas you referenced?
I've implemented a couple of arrangements that might be of interest (using passwd files) at https://github.com/rorycl/dovecot-config#examples
The two-userdbs example is an example of using separate user databases.
The no-domain example might be helpful separately; it's an example of using the same user database for domain-less and domain qualified users.
You can run these easily with Docker. I'd be grateful to know what you and Odhiambo think.
Regards, Rory