diff -Naur roundcubemail.orig/config/main.inc.php.dist roundcubemail.new/config/main.inc.php.dist
--- roundcubemail.orig/config/main.inc.php.dist	Sun Nov 13 10:27:17 2005
+++ roundcubemail.new/config/main.inc.php.dist	Sun Nov 13 14:31:57 2005
@@ -33,6 +33,14 @@
 // To use SSL connection, enter ssl://hostname:993
 $rcmail_config['default_host'] = '';
 
+// When administering webmail for more than 1 domain's email on the same IMAP server
+// and users need to login with their full email address, provide a select box
+// with all of the domains being serviced.  @domain.com is then appended
+// to the username before being sent to the IMAP server.
+// e.g. $rcmail_config['login_domains'] = array('foo.com','bar.org');
+$rcmail_config['login_domains'] = array();
+
+
 // TCP port used for IMAP connections
 $rcmail_config['default_port'] = 143;
 
diff -Naur roundcubemail.orig/index.php roundcubemail.new/index.php
--- roundcubemail.orig/index.php	Sun Nov 13 10:27:17 2005
+++ roundcubemail.new/index.php	Sun Nov 13 14:52:58 2005
@@ -114,13 +114,14 @@
 if ($_action=='login' && $_task=='mail')
   {
   $host = $_POST['_host'] ? $_POST['_host'] : $CONFIG['default_host'];
-  
+  $domain = $_POST['_domain'] ? $_POST['_domain'] : null;
+
   // check if client supports cookies
   if (empty($_COOKIE))
     {
     show_message("cookiesdisabled", 'warning');
     }
-  else if (isset($_POST['_user']) && isset($_POST['_pass']) && rcmail_login($_POST['_user'], $_POST['_pass'], $host))
+  else if (isset($_POST['_user']) && isset($_POST['_pass']) && rcmail_login($_POST['_user'], $_POST['_pass'], $host,$domain))
     {
     // send redirect
     header("Location: $COMM_PATH");
@@ -302,4 +303,4 @@
                   'file' => __FILE__,
                   'message' => "Invalid request"), TRUE, TRUE);
                       
-?>
\ No newline at end of file
+?>
diff -Naur roundcubemail.orig/program/include/main.inc roundcubemail.new/program/include/main.inc
--- roundcubemail.orig/program/include/main.inc	Sun Nov 13 10:27:17 2005
+++ roundcubemail.new/program/include/main.inc	Sun Nov 13 15:02:51 2005
@@ -30,7 +30,7 @@
 
   // check client
   $BROWSER = rcube_browser();
-
+ 
   // load config file
   include_once('config/main.inc.php');
   $CONFIG = is_array($rcmail_config) ? $rcmail_config : array();
@@ -245,11 +245,15 @@
 
 
 // perfom login to the IMAP server and to the webmail service
-function rcmail_login($user, $pass, $host=NULL)
+function rcmail_login($user, $pass, $host=NULL, $domain=null)
   {
   global $CONFIG, $IMAP, $DB, $sess_user_lang;
   $user_id = NULL;
   
+  // add @domain if $domain is set.
+  //
+  $user = $domain ? "$user@$domain" : $user;
+
   if (!$host)
     $host = $CONFIG['default_host'];
 
@@ -1034,16 +1038,27 @@
   $labels['user'] = rcube_label('username');
   $labels['pass'] = rcube_label('password');
   $labels['host'] = rcube_label('server');
+  $labels['dom'] = rcube_label('domain');
   
   $input_user = new textfield(array('name' => '_user', 'size' => 30));
   $input_pass = new passwordfield(array('name' => '_pass', 'size' => 30));
   $input_action = new hiddenfield(array('name' => '_action', 'value' => 'login'));
-    
+
   $fields = array();
   $fields['user'] = $input_user->show($_POST['_user']);
   $fields['pass'] = $input_pass->show();
   $fields['action'] = $input_action->show();
-  
+
+  if (is_array($CONFIG['login_domains']) && count($CONFIG['login_domains']) > 0)
+    {
+    $select_domain = new select(array('name' => '_domain'));
+    
+    foreach ($CONFIG['login_domains'] as $key => $value)
+      $select_domain->add($value, (is_numeric($key) ? $value : $key));
+      
+    $fields['domain'] = $select_domain->show($_POST['_domain']);
+    }
+
   if (is_array($CONFIG['default_host']))
     {
     $select_host = new select(array('name' => '_host'));
@@ -1062,6 +1077,17 @@
   $form_name = strlen($attrib['form']) ? $attrib['form'] : 'form';
   $form_start = !strlen($attrib['form']) ? '<form name="form" action="./" method="post">' : '';
   $form_end = !strlen($attrib['form']) ? '</form>' : '';
+
+
+  if ($fields['domain'])
+    $form_domain = <<<EOF
+
+</tr><tr>
+
+<td class="title">$labels[dom]</td>
+<td>$fields[domain]</td>
+
+EOF;
   
   if ($fields['host'])
     $form_host = <<<EOF
@@ -1086,8 +1112,10 @@
 
 </tr><tr>
 
+
 <td class="title">$labels[pass]</td>
 <td>$fields[pass]</td>
+$form_domain
 $form_host
 </tr></table>
 $form_end
@@ -1097,4 +1125,4 @@
   }
 
 
-?>
\ No newline at end of file
+?>
diff -Naur roundcubemail.orig/program/localization/en/labels.inc roundcubemail.new/program/localization/en/labels.inc
--- roundcubemail.orig/program/localization/en/labels.inc	Sun Nov 13 10:27:17 2005
+++ roundcubemail.new/program/localization/en/labels.inc	Sun Nov 13 10:48:23 2005
@@ -23,6 +23,7 @@
 $labels['password']  = 'Password';
 $labels['server']    = 'Server';
 $labels['login']     = 'Login';
+$labels['domain']    = 'Domain';
 
 // taskbar
 $labels['logout']   = 'Logout';
@@ -176,4 +177,4 @@
 $labels['sortasc']  = 'Sort ascending';
 $labels['sortdesc'] = 'Sort descending';
 
-?>
\ No newline at end of file
+?>
