wiki:Howto_Config

Version 12 (modified by cchantep, 4 years ago) (diff)

multiple host domain

IMAP server configuration

By default the login screen provides a text box where you need to enter the IMAP host which you want to connect to. This box can be hidden by setting one fixed IMAP host address:

$rcmail_config['default_host'] = 'localhost';

And if you want a dropdown list like it's explained in the comments you need something like this:

$rcmail_config['default_host'] = array('mail.example.com', 'webmail.example.com', 'ssl://mail.example.com:993');

In order to show nice labels instead of the host names in the dropdown box write it that way:

$rcmail_config['default_host'] = array(
  'mail.example.com' => 'Default Server',
  'webmail.example.com' => 'Webmail Server',
  'ssl://mail.example.com:993' => 'Secure Webmail Server'
);

Auto create user

Sometimes hard to understand is the 'auto_create_user' property in main.inc.php. If set to True a new RoundCube user is created once the IMAP login succeeds. If auto_create_user is set to False, the login only succeeds if there's a matching user-record in the local RoundCube database. Even if a user enters the correct password and the IMAP login succeeds, the login will fail with the message "Login failed".

Deleted messages

Some mail clients just mark messages as deleted and finally remove them when leaving the application. RoundCube by default move messages to the Trash folder when hitting the delete button. However this behavior can be changed by unsetting the 'trash_mbox' property and enabling 'flag_for_deletion'. Your configuration could look like this:

$rcmail_config['trash_mbox'] = '';
$rcmail_config['flag_for_deletion'] = true;
$rcmail_config['skip_deleted'] = false;

Messages will now be marked as deleted which can be reverted again. To finally remove them, the user needs to click "Compact" below the folder list.

Configuring for Virtual Users

Virtual users are useful for hosting providers where a single mailserver is providing email for a number of different domains. The goal is that the user logs in to roundcube with their email login/password, and roundcube knows where to lookup their complete email address. Two options are support, SQL lookups or a sendmail style virtuser file.

In order to test if virtuser is configured correctly, log in to roundcube with a user that does not exist yet. Compose a message, if you see the From address as user@correct_domain, then it worked. If you see user@localhost, something is wrong. To reset and try again, delete that user from the roundcube users and identities tables.

1) virtuser_file

$rcmail_config['virtuser_file'] = '/etc/mail/virtuser';

This assumes that the file /etc/mail/virtuser contains information about your virtual users in the following format:

user@domain login1
user@domain login2

2) virtuser_query (SQL)

$rcmail_config['virtuser_query'] = "SELECT email_address FROM database.table WHERE login = '%u'";

If you are using postfix and/or some kind of hosting panel, chances are your email accounts are already stored in a SQL table. If that is the case, you want to lookup the emails with a virtuser_query. The parts of the example query:

// email_address - the first column returned by the query must be the complete email address
// database - name of the database where your table is located, the roundcube db user must have read access
// table - name of the table where your email addresses are stored
// login - name of the field that contains the username that is used to log in to roundcube (and send/receive email)

Alternate Solution for the Multiple Host Domain (dynamic)

In case you have one installation of RoundCube to server multiple domains you can create host-specific config files. These files have to be named like [hostname].inc.php and also be located in the config directory. RoundCube does not read them by default so you need to enable the 'include_host_config' option in the main config file.

Instead of setting 'include_host_config' to true, you can specify an associative array assigning host names (key) to config file names (values) like the following example

$rcmail_config['include_host_config'] = array(
  'mail.roundcube.net' => 'net_config.inc.php',
  'mail.roundcube.com' => 'com_config.inc.php'
);

Please note that the host-specific configurations will be merged over the main config file what means that they only need to contain the parameters that differ from the main configuration.

If you want multiple host domain, but also want to avoid user to be able to sign on domain other than theirs (e.g. Avoid user@… to be able to log in user@…) -- because settings of one domain must not be used on other --, it's possible to add session check in host-specific config files :

// load and check session data
if (session_id() == '') {
  session_start();
}

$username = NULL;

if (isset($_SESSION['auth_time']) && isset($_SESSION['username'])) {
  // is logged in
  $username = $_SESSION['username'];
}

With such code in host-specific config file, you can check $username (and its domain).