On Friday, May 2 at 01:54 AM, quoth Kanwar Ranbir Sandhu:
I've never played with that... I prefer things I can read all at once.
Here's what I do:
$vdomainmapping = array( 'domain1.com' => 'domain1.com', 'www.domain1.com' => 'domain1.com', 'domain2.com' => 'domain2.com', 'www.domain2.com' => 'domain2.com', ); if (isset($vdomainmapping[$_SERVER['HTTP_HOST']])) { $rcmail_config['username_domain'] = $vdomainmapping[$_SERVER['HTTP_HOST']]; } else { $rcmail_config['username_domain'] = ''; }
Firstly, where do I put that?
I put it in the config/main.inc.php file.
Secondly, why the hell is any of that necessary when roundcube is supposed to have easily configurable, built in support for multiple domains?! I'm absolutely dumb founded.
Well, I started doing it that way when I first started using roundcube, which was a while ago. If they've improved things since, I haven't noticed.
But some of the comments in the config file are misleading. For example, the comment preceeding username_domain in there says:
Automatically add this domain to user names for login
Only for IMAP servers that require full email-addresses for login
Specify an array with 'host' => 'domain' values to support
multiple hosts
What they don't tell you is that "host" is not matched against $_SERVER['HTTP_HOST'], but is instead matched against the *IMAP SERVER NAME*. As you can see in program/include/rcmail.php, the matching is done against a variable named $host - the test is:
isset($config['username_domain'][$host])
And what is $host? It gets defined just above there, from $config['default_host'], which is the IMAP server.
You may be asking yourself "why in hell would they do that?!?"; the answer is because of a different feature. You can configure RoundCube to serve as a frontend for multiple IMAP servers, with a popup box on the login window allowing you to select them. So you could, for example, set up the same RoundCube to be a frontend for both your personal email and your work email, and all you have to do is select which one you're logging in to. Then all the necessary configuration options automatically change to match the server that you've chosen to log into.
Okay, so, it's still a pretty pointless feature for what most people want to use RoundCube *for*, but that's what they're doing. So in most places in the documentation, where they say "host", they're using an unusual definition of the term. Rather than "the domain on which this webmail is being hosted" what they really mean is "the imap server to which this webmail is connecting". So, for people who just have several virtual domains on the same server, this feature is *entirely useless* because $host is always going to be 'localhost'.
Once you realize that the developers have a unique perspective here, things start to make more sense.
I hadn't seen the "include_host_config" option before. From looking at the source, while this does indeed match based on $_SERVER['HTTP_HOST'] and looks like it would do the right thing... it's only used in a function (load_host_config) that is NEVER ACTUALLY CALLED, so those files will never be read. Which is probably the primary reason why include_host_config isn't documented or included in the main.inc.php file.
~Kyle
P.S. For what it's worth, I just created a bug for this (http://trac.roundcube.net/ticket/1485040)