There are a lot of different ways to configure Roundcube Webmail to handle multiple domains. In an effort to have a similar experience to my legacy webmail system, I wanted Roundcube to have a drop-down list of domains/servers to login to.
To enable this I set the following in /etc/roundcubemail/main.inc.php :
$rcmail_config['default_host'] = array(
'mail99.techsneeze.com' => 'TechSneeze',
'mail3.example.com' => 'Example Domain',
'mail.biz.example.com' => 'Example Business Users'
This worked great for allowing the appropriate logins to work, and provide the user experience that was desired. However, Roundcube was not automatically setting identities correctly for new users when they logged in. Looking through the documentation, it was clear that “mail_domain” needed to be configured correctly. I tried using “%h” and “%z” as the setting, but they were essentially causing it to be a null domain for the identity. I then realized I hadn’t red the comments in the config file correctly, and determined I needed an array of hostnames to domains! The config section ended up looking like :
$rcmail_config['mail_domain'] = array(
'mail99.techsneeze.com' => 'techsneeze.com',
'mail3.example.com' => 'example.com',
'mail.biz.example.com' => 'biz.example.com'
You’ll see that this creates a mapping between the server listed in the earlier section, to the appropriate domain to append to the users login name.