What options exist for changing usernames transparently in Webmail?
Solution 1:
This problem can be tackled either in roundcube, dovecot or your username-backend.
Roundcube has option to auto append domain parts if no domain provided (as proposed by Kondybas). But it won't too useful in your case. Of course you can patch roundcube (with PHP language) to adding your logic.
Dovecot has option to strip domain (as proposed in Dovecot user lookup fails when using username@domain format) but it can't do conditional stripping (e.g. strip domain if domain = @ourdomain.com). Of course you can patch dovecot (with C language) to adding your logic.
Username-backend is also option too. You don't give the backend you use (either SQL, LDAP, custom engine). I can imagine that you have username column that have two format with and without domain. Now, you can convert all username without domain become username@ourdomain. You can combine this process with option 1 (roundcube auto append domain) so either username and username@ourdomain can login.
Solution 2:
RoundCube
have an option called username_domain
// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['username_domain'] = '';
If you have used subdirectory (like ourdomain.tld/roundcube
) set this option to the
$config['username_domain'] = '%n';
If you have used subdomains (like mail.domain.tld
) set this option to the
$config['username_domain'] = '%t';
When user provide his full email as login, that email will be used without any changes. If domain part is omitted, RoundCube
will use the URL-domain for completion.
Also there is number of neat options in the roundcube's config.