View Single Post
Old 20th May 2010, 23:04
austingecko austingecko is offline
Junior Member
Join Date: May 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

This thread caught my attention...while I don't yet run in a multiserver environment I liked the idea and concept to do so with a centralized Roundcube install location. A query based approach would seem doable as Hans indicated the server_id is in the "mail_user" table which could be queried with a join to the "server" table in the "dbispconfig" database to retrieve the "server_name" value.

I poked around and found in the Roundcube directory:


 $auth = $RCMAIL->plugins->exec_hook('authenticate', array(
    'host' => $RCMAIL->autoselect_host(),
    'user' => trim(get_input_value('_user', RCUBE_INPUT_POST)),
    'cookiecheck' => true,
  )) + array('pass' => get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-88$

  public function autoselect_host()
    $default_host = $this->config->get('default_host');
    $host = null;

    if (is_array($default_host)) {
      $post_host = get_input_value('_host', RCUBE_INPUT_POST);

      // direct match in default_host array
      if ($default_host[$post_host] || in_array($post_host, array_values($defau$
        $host = $post_host;

      // try to select host by mail domain
      list($user, $domain) = explode('@', get_input_value('_user', RCUBE_INPUT_$
      if (!empty($domain)) {
        foreach ($default_host as $imap_host => $mail_domains) {
          if (is_array($mail_domains) && in_array($domain, $mail_domains)) {
            $host = $imap_host;

      // take the first entry if $host is still an array
      if (empty($host)) {
        $host = array_shift($default_host);
    else if (empty($default_host)) {
      $host = get_input_value('_host', RCUBE_INPUT_POST);
      $host = $default_host;

    return $host;
Seems like one should be able to modify the autoselect_host function to include a SQL query and return the right host/server needed.

Hopefully someone with PHP/MySQL programming experience will come along and contribute and knock this out for you.
Reply With Quote