How To Configure RoundCube WebMail On Ubuntu
Introduction
In this tutorial, you will learn how to download, install, and Configure RoundCube WebMail using Nginx Webserver. RoundCube will be configured to use secure TLS and SSL connections.
Prerequisites
- Root access, or a non-root user with sudo privileges for downloading RoundCube.
- An SSL enabled domain name. If you don’t have one yet, read the LetsEncrypt tutorial.
- An Email Server up and running. In case you haven’t set one yet, take the Postfix-Dovecot tutorial.
Step 1 – Download RoundCube WebMail Client
sudo wget https://github.com/roundcube/roundcubemail/releases/download/1.4.10/roundcube-framework-1.4.10.tar.gz
sudo tar xzf roundcubemail-1.3.10-complete.tar.gz
sudo mv roundcubemail-1.3.10 /usr/share/
sudo mv /usr/share/roundcubemail-1.3.10 /usr/share/mail
Your RoundCube installation now resides in /usr/share/mail. The next step is to create the MySQL database required.
Step 2 – Create The MySQL Database
We will create the Roundcube database, create a user, and then assign full privileges on that database for the specific user.
sudo mysql -u root -p
mysql> CREATE DATABASE IF NOT EXISTS `roundcube` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)
mysql> USE roundcube;
Database changed
mysql> CREATE USER 'roundcubeuser'@'localhost' IDENTIFIED BY 'RoundCubeUserPassword';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON `roundcube`.* TO 'roundcubeuser'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
There is no need to create tables on the database, because RoundCube will create them automatically during its Web Interface setup.
Step 3 – Configure RoundCube Nginx Location
For simplicity and maintainability reasons, we will use the folder “snippers” located in /etc/nginx/snippets, and will will create our configuration file in it. This can be done like so:
sudo vi /etc/nginx/snippets/mail.conf
And paste the location code below:
location /mail {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/mail/(.+.php)$ {
root /usr/share/;
include fastcgi_config;
}
location ~* ^/mail/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
And then open your main site configuration file, and add:
include snippets/*.conf;
Just before the last closing bracket.
In Nginx, when a folder is included in configuration with the *.conf suffix, it means that all .conf files within that folder will be enabled.
Step 4 – RoundCube Configuration
Vist the location where roundcube is installed. In our example is example.com/mail
.
Normally you will see the RoundCube login screen, but we need to make some extra configuration for the database connection. For that you will have to visit example.com/mail/installer
. The screen you will see, will look very symilar with the one below.
Checking PHP version
Version: OK(PHP 7.3.10-1+ubuntu18.04.1+deb.sury.org+1 detected)
Checking PHP extensions
The following modules/extensions are required to run Roundcube:
PCRE: OK
DOM: OK
Session: OK
XML: OK
JSON: OK
PDO: OK
Multibyte: OK
OpenSSL: OK
The next couple of extensions are optional and recommended to get the best performance:
FileInfo: OK
Libiconv: OK
Intl: NOT AVAILABLE(See http://www.php.net/manual/en/book.intl.php)
Exif: OK
LDAP: NOT AVAILABLE(See http://www.php.net/manual/en/book.ldap.php)
GD: OK
Imagick: NOT AVAILABLE(See http://www.php.net/manual/en/book.imagick.php)
Checking available databases
Check which of the supported extensions are installed. At least one of them is required.
MySQL: OK
PostgreSQL: NOT AVAILABLE(See http://www.php.net/manual/en/ref.pdo-pgsql.php)
SQLite: NOT AVAILABLE(See http://www.php.net/manual/en/ref.pdo-sqlite.php)
SQLite (v2): NOT AVAILABLE(See http://www.php.net/manual/en/ref.pdo-sqlite.php)
SQL Server (SQLSRV): NOT AVAILABLE(See http://www.php.net/manual/en/ref.pdo-sqlsrv.php)
SQL Server (DBLIB): NOT AVAILABLE(See http://www.php.net/manual/en/ref.pdo-dblib.php)
Oracle: NOT AVAILABLE(See http://www.php.net/manual/en/book.oci8.php)
Check for required 3rd party libs
This also checks if the include path is set correctly.
PEAR: OK
Auth_SASL: OK
Net_SMTP: OK
Net_IDNA2: OK
Mail_mime: OK
Net_LDAP3: OK
Checking php.ini/.htaccess settings
The following settings are required to run Roundcube:
file_uploads: OK
session.auto_start: OK
mbstring.func_overload: OK
suhosin.session.encrypt: OK
The following settings are optional and recommended:
allow_url_fopen: OK
date.timezone: OK
Next click on “Create Config”. In this page we are only interested in the Database setup information. Fill in the appropriate values that you have choosen during the MySQL user creation (Database name, user, and password, and click update config.
Now a new configuration file will be created (config.inc.php) which needs to be edited. Open it with vi like so :
sudo vi /usr/share/mail/config/config.inc.php
You will notice that the $config[‘db_dsnw’] varible is a little weird, and this is actually the only variable that you need to keep for your current config.inc.php. Feel free to delete all the rest, and replace them with the code below:
/* Local configuration for Roundcube Webmail */
// ----------------------------------
// SQL DATABASE
// ----------------------------------
// Database connection string (DSN) for read+write operations
// Format (compatible with PEAR MDB2): db_provider://user:password@host/database
// Currently supported db_providers: mysql, pgsql, sqlite, mssql, sqlsrv, oracle
// For examples see http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php
// NOTE: for SQLite use absolute path (Linux): 'sqlite:////full/path/to/sqlite.db?mode=0646'
// or (Windows): 'sqlite:///C:/full/path/to/sqlite.db'
$config['db_dsnw'] = 'mysql://roundcubeuser:RoundCubeUserPassword@localhost/roundcube';
// ----------------------------------
// IMAP
// ----------------------------------
// The IMAP host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
// required to match old user data records with the new host.
// IMAP
$config['default_host'] = 'ssl://mail.example.com';
// TCP port used for IMAP connections
$config['default_port'] = 993;
// IMAP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or null to use
// best server supported one)
$config['imap_auth_type'] = 'LOGIN';
// IMAP socket context options
// See http://php.net/manual/en/context.ssl.php
// The example below enables server certificate validation
//$config['imap_conn_options'] = array(
// 'ssl' => array(
// 'verify_peer' => true,
// 'verify_depth' => 3,
// 'cafile' => '/etc/openssl/certs/ca.crt',
// ),
// );
// Note: These can be also specified as an array of options indexed by hostname
$config['imap_conn_options'] = array (
'ssl' =>
array (
'verify_peer' => false,
'verify_peer_name' => false,
),
);
// If you know your imap's folder delimiter, you can specify it here.
// Otherwise it will be determined automatically
$config['imap_delimiter'] = '/';
// ----------------------------------
// SMTP
// ----------------------------------
// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['smtp_server'] = 'tls://mail.example.com';
// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
// deprecated SSL over SMTP (aka SMTPS))
$config['smtp_port'] = 587;
// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
$config['smtp_user'] = '%u';
// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
$config['smtp_pass'] = '%p';
// SMTP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or empty to use
// best server supported one)
$config['smtp_auth_type'] = 'LOGIN';
// Required if you're running PHP 5.6 or later
$config['smtp_conn_options'] = array (
'ssl' =>
array (
'verify_peer' => false,
'verify_peer_name' => false,
),
);
// provide an URL where a user can get support for this Roundcube installation
// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
$config['support_url'] = '';
// this key is used to encrypt the users imap password which is stored
// in the session record (and the client cookie if remember password is enabled).
// please provide a string of exactly 24 chars.
$config['des_key'] = 'your_d';
// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['username_domain'] = 'example.com';
// Name your service. This is displayed on the login screen and in the window title
$config['product_name'] = 'My Webmail Interface';
// ----------------------------------
// PLUGINS
// ----------------------------------
// List of active plugins (in plugins/ directory)
$config['plugins'] = array('acl', 'additional_message_headers', 'archive', 'attachment_reminder', 'emoticons', 'filesystem_attachments', 'help', 'identicon', 'identity_select', 'jqueryui', 'managesieve', 'markasjunk', 'new_user_identity', 'newmail_notifier', 'password', 'show_additional_headers', 'subscriptions_option', 'userinfo', 'vcard_attachments', 'virtuser_query', 'zipdownload');
// USER INTERFACE
$config['create_default_folders'] = true;
// if in your system 0 quota means no limit set this option to true
$config['quota_zero_as_unlimited'] = true;
// USER PREFERENCES
$config['default_charset'] = 'UTF-8';
//$config['addressbook_sort_col'] = 'name';
$config['draft_autosave'] = 60;
// If true all folders will be checked for recent messages
$config['check_all_folders'] = true;
// Default messages listing mode. One of 'threads' or 'list'.
$config['default_list_mode'] = 'threads';
// 0 - Do not expand threads
// 1 - Expand all threads automatically
// 2 - Expand only threads with unread messages
$config['autoexpand_threads'] = 2;
// Default font size for composed HTML message.
// Supported sizes: 8pt, 10pt, 12pt, 14pt, 18pt, 24pt, 36pt
$config['default_font_size'] = '12pt';
// Enables display of email address with name instead of a name (and address in title)
$config['message_show_email'] = true;
Save the file, and exit.
You will normally now be able to send a receive emails using RoundCube WebMail!