Multiple domains login in roundcube webmail

Roundcube is very good solution for webmail. I use squirrelmail for almost 4 years and I like it too.

In production server I install squirrelmail and roundcube as well for give other user different experience :-)

using mail and mail2 as prefix and multiple domains need special attention in roundcube.

After search in their forum I like this snippet :

 function getDomain() {

    $host=$_SERVER[‘HTTP_HOST’];

    $prefix=’mail’;

    $arr=explode(‘.’,$host);

    if ($arr[0]==$prefix) { unset($arr[0]); $host=implode(‘.’,$arr); }

    else { $host=”; }

    return $host;

}

plus this line :

$rcmail_config[‘username_domain’] = getDomain();

 put that in config/main.inc.php

for my case where I use mail and mail2 just edit the line :

if ($arr[0]==$prefix) { unset($arr[0]); $host=implode(‘.’,$arr); }

into

if ($arr[0]==$prefix or $arr[0]==’mail2′) {

unset($arr[0]); $host=implode(‘.’,$arr);

}

 Working  well for me :-)