How to install and configure Horde 5 webmail on Debian/Ubuntu

Horde is a webapp framework probably best known for its webmail client. In this tutorial, you’ll be guided step-by-step through how to set up the Horde webmail and contacts manager against an IMAP email server.

This tutorial is suited for sysadmins who have already setup their own personal email hosting or hosts it for a small team, and who want to add webmail and groupware functionality.

IMAP and SMPT must already be set up and functional, and you should already have a web server setup with a domain and encryption certificates. You can proceed with this tutorial and configure your web server later if you just want to get going. Horde doesn’t need to be installed on your email server, but must be able to reach it via IMAP and SMTP over the network.

The tutorial assumes your server is running Debian 8.1 ”Jessie” or newer, or Ubuntu 15.04 “Vivid” or newer. Other distributions and versions may have file paths and package management systems that will vary from these instructions. The concepts discussed and the Horde configurations necessary will, however, remain the same across distributions so it should be useful to you regardless of your distribution.

Unlike many other programs, Horde isn’t forgiving if you don’t configure it properly and you can easily get yourself in a situation that it’s hard to get back out of. Take care to read the instructions thoroughly. Take a backup of a working instance, and only adjust settings for your needs after getting everything up and running.

Installing Horde

  1. Pull up a root-shell and execute each of these commands in turn:
    1. apt-get update
    2. apt-get install php-horde-webmail php5-sqlite

Without any configuration needed, Apache will now be installed, and Horde itself should be up and running. By default, Horde will be made available on any server or virtual host on any protocol (HTTP and HTTPS) under the alias /horde.

Configuring the web server is beyond the scope of this how-to, but the configuration file that makes this happen is available in /etc/apache2/conf-available/php-horde.conf and should be disabled using the command a2disconf php-horde once you’ve copied the contents of that configuration file into the configuration file of your server. You can ignore all of this and get back to configuring your web server later if you just want to get Horde up and running before committing too much time and energy to the project.

When the tutorial refers to “localhost”, use your server’s domain name instead unless you’re installing Horde on your local computer.

Configuring Horde

This section is split up in two sub-sections based on where the work takes place. We’ll start in the terminal and then make the jump into Horde’s web administration interface.

Terminal configurations

We’ll start by creating a few configuration files and data storage directories and making them readable by Horde. This will allow us to configure almost everything in Horde’s web interface rather than messing around too much in the terminal.

  1. Pull up a root-shell and execute each of these commands in turn. Each item is one line of command instructions:
    1. mkdir /var/lib/horde/
    2. chown www-data:www-data /var/lib/horde/
    3. cp /etc/horde/horde/conf.php.dist /etc/horde/horde/conf.php
    4. chown www-data:www-data /etc/horde/horde/conf.php
    5. touch /etc/horde/imp/conf.php /etc/horde/turba/conf.php
    6. chown www-data:www-data /etc/horde/imp/conf.php /etc/horde/turba/conf.php
    7. cp /etc/horde/imp/backends.php /etc/horde/imp/backends.local.php

The last thing to do in the terminal before proceeding into the web administration interface is letting Horde know about your IMAP server so that you may use it to login to Horde. We need to edit one configuration file using the shell:

  1. nano /etc/horde/imp/backends.local.php
  2. Scroll down to the “imap” server block, and adjust it to your IMAP server. It should look something like this:
$servers['imap'] = array(
  'disabled' => false,
  'name' => 'My IMAP server',
  'hostspec' => '',
  'hordeauth' => false,
  'protocol' => 'imap',
  'secure' => 'tls',
  1. Press Control + X and confirm to save the changes to the file.

You’re now ready to make the jump over into the web administration interface.

Web administration interface

Next, we’ll step into the web interface. Please don’t click the Generate Config button at the bottom of each page in the web interface before instructed to do so as you’ll end up locking yourself out of the administration interface if you’re too eager.

We’ll start by setting up the webmail and contacts apps. There’s no configuration required as the default will work just fine, but it requires a configuration file to exist to flag the app as “enabled”.

  1. Open up http://localhost/horde and click on “Mail (imp)” from the list
  2. Click Generate Mail Configuration
  3. Open up http://localhost/horde and click on “Addres Book (turba)”
  4. Click Generate Address Book Configuration

With the two apps configured, it’s time to bring Horde itself to life.

  1. Open up http://localhost/horde
  2. Click “Horde (horde)”
  3. Under General you should review the “URL Settings” section, this is where you enable encryption (HTTPS) and set your webmail server’s domain name. If you don’t set a server name here, you must scroll down to Session Settings: and uncheck use_only_cookies.
  4. Click on the Database tab
  5. Select SQLite as the database backend
  6. Enter /var/lib/horde/db.sqlite as the absolute path

You should consider using a more powerful database system than SQLite for larger deployments. However, it’s easy to set up and backup, and will do fine for a small team or personal deployment.

Next we’ll choose to let the webmail app (imp) handle logins. This will mean that users will login to Horde reusing their existing IMAP accounts and credentials.

  1. Click the Authentication tab
  2. Enter the username of at least one or more IMAP users that will have access to the administration interface
  3. Scroll down to auth driver and choose Let a Horde application handle authentication
  4. Select “imp” in the drop-down below the driver choice

Lastly, Horde needs to know about your SMTP server for outgoing emails.

  1. Click the Mailer tab
  2. Choose SMTP Server from the drop-down list
  3. Fill in the details like address and port to your SMTP server
  4. Choose to authenticate to the SMTP server, but leave the fields below it untouched. That way users will re-use their IMAP credentials with the SMTP server.
  5. Click Generate Horde Configuration

The very last step is to populate the SQLite database with schemas needed by Horde. The SQLite database is used to store each user’s preferences and some app data.

  1. Pull up a root-shell and execute the following command:
    1. horde-db-migrate

You’re done now. Horde should be up and running with the webmail and contacts app available to users.

Setting up calendar and other apps

You’ve already set up the webmail and contacts apps, but Horde offers a suite of other applications that you’re already ready to use. To add Horde’s calendar appointment application, Kronolith, follow the below steps:

  1. touch /etc/horde/kronolith/conf.php
  2. chown www-data:www-data /etc/horde/kronolith/conf.php
  3. Open http://localhost/horde/admin/config/config.php?app=kronolith
  4. click Generate Configuration (no need to change anything)

You can repeat the above steps for configuring the calendar application to configure the other apps listed below. Replace the highlighted app name with one of the following extra apps as you need them. As with the calendar app, there’s no need to adjust the app configuration in any way. Learn more about the different Horde apps.

imp Webmail (Already configured)
ingo Filters
turba Contacts (Already configured)
kronolith Calendar (Already configured)
gollem File hosting
mnemo Notebook
nag To-do / reminders
tream Web bookmarks

Backing up and restoring from backup

To back up your Horde installation, you need only to make copies of the two directories /etc/horde/ for configurations and /var/lib/horde/ for user-data. If you don’t have a system in place for backups yet, you can use the below guidance for inspiration.

  1. Pull up a root-shell and execute the following command:
tar -zcvf horde-backup.tar.gz /etc/horde /var/lib/horde

Store this file with your regular off-system backup dataset. There should be no sensitive data in /etc/horde, but /var/lib/horde may contain contacts, calendar, and other app data for each user. The backup command should be re-run on a regular basis, for example using a cron job. Separate from Horde, you will also need to back up your web server configuration and your IMAP server to fully restore a working Horde instance.

To restore from your backup, you first need to install Horde on your system by completing the Installation section. You can then restore your Horde configuration and user data.

  1. Pull up a root-shell and execute the following command:
tar -zxvf horde-backup.tar.gz -C /

Separate from Horde, you also need to restore your web server configuration.

Connecting clients

At this point, you should be all set up to go and users. By default, users’ contact lists is accessible via the open standard protocol CardDAV and their calendars via CalDAV. CardDAV and CalDAV support comes built-in to iOS and Mac OS X, but requires add-on programs for Android and other operating systems.

The web manager will be available to operate systems and clients without CalDAV/CardDAV support. The DAV addresses to each user’s contact list and calendar is available to each user inside those applications.

Optionally, you can enable Microsoft Exchange ActiveSync for clients that don’t support CalDAV/CardDAV such as Microsoft Outlook and Windows 10 Mobile. Note that using the Exchange protocol may require a site license depending on where in the world you’re located.

Update (): Debian bug #782537 may cause problems with address book auto-completion and other JavaScript issues. See the bug for details on how to correct it.