Web-based Email on the Horde Platform

Believe it or not, IT departments shudder at the words "Let's deploy Exchange." Although Microsoft's email server is virtually ubiquitous, that doesn't mean it's popular with those that have to manage it. So before your boss writes a hefty check for Exchange and sentences you to countless hours of hard labor, speak up and suggest one of the many open source substitutes that are just as robust as Exchange -- and are free!

Believe it or not, IT departments shudder at the words “Let’s deploy Exchange.” Although Microsoft’s email server is virtually ubiquitous, that doesn’t mean it’s popular with those that have to manage it. So before your boss writes a hefty check for Exchange and sentences you to countless hours of hard labor, speak up and suggest one of the many open source substitutes that are just as robust as Exchange — and are free!

The Horde Project is one of those alternatives. It’s constantly refined, is widely deployed within small organizations and Fortune 500 companies alike, and has an active support network via mailing lists and support archives.

Joining the Horde

Created by Chuck Hagenbuch, Horde (http://www.horde.org) is a PHP-based application framework for building and deploying web applications. By itself, Horde doesn’t serve an obvious purpose for the end-user, as it only provides programming interfaces (APIs) for external applications. (Horde provides features such as authentication, browser matching, user preference management, MIME handling, inter-application communication, internationalization, and many more.) However, if you combine horde with Hagenbuch’s popular IMP web-based mail program, you get a system that easily rivals the features of Exchange. (IMP is just one of many Horde applications. Other Horde applications include Turba, a contact manager for SQL or LDAP sources; Kronolith, a calendar event manager for MCAL or SQL sources; NAG, a to-do list manager; and Jonah, a syndicated headlines retrieval system. See the Horde module page at http://www.horde.org/source/modules.php for a complete list of applications.)

Getting Started with Horde

For this article, the test system used IMP 3.2 running on top of Horde 2.2.

In addition to the Horde software, you’ll need a functioning IMAP server and an operational MySQL database server. These services can run on machines other than the Horde server, but for best performance, all of the software should run on your local network and not across the Internet.

There are several prerequisites for Horde and IMP. Perhaps the biggest challenge of getting Horde set up properly is compiling PHP with all of the required and recommended capabilities.

Create a PHP script that executes phpinfo() and check the results against these specifications: PHP 4.1.0 or above, compiled with the –with-apxs option; Gettext support (–with-gettext); XML support (–with-xml); IMAP support (–with-imap); one of –with-mysql, –with- pgsql, –with-oracle, or –with-ldap; Mcrypt support (–with-mcrypt); Sendmail or equivalent; and all of the Log, Mail_Mime, and Net_Socket PEAR modules.

If you’ve never installed a PEAR library before, it’s quite easy, if you’ve compiled a version of PHP without –with -apxs. If so, just type pear install Log to make the Log library available to your applications. (For more information on PEAR, visit http://pear.php.net.)

Tarballs for Horde are available on Horde’s FTP site located at ftp://ftp.horde.org/pub. Enter the Horde directory and download the latest 2.x version (as the magazine went to press, the latest version was horde-2.2.5.tar.gz. Then, enter the IMP directory and download the last 3.x release (most recently, imp-3.2.4.tar.gz).

Now that you have the software downloaded to your system, unpack the Horde package off the document root directory of your web server. For example, if your document root is /usr/local/apache/htdocs, you’d type:

# cd /usr/local/apache/htdocs
# tar -xzvf horde-2.2.5.tar.gz
# mv horde-2.2.5 horde

Your installation is now available as http://server/horde. Next, unpack the IMP package into the horde directory you just created.

For example, if Horde is installed in /usr/local/apache/ htdocs/horde/, you’d type:

# cd /usr/local/apache/htdocs/horde
# tar -xzvf imp-3.2.4.tar.gz
# mv imp-3.2.4 imp

Now that your directory structure is set, create the MySQL data structure.

Change directory to horde/db/scripts/ and execute mysql_ create.sql. The script horde/db/scripts/mysql_create.sql installs the data structure in your local MySQL instance and grants the horde@localhost user full privileges to the database horde. If you need to, edit this script to change the database password to suit various remote database server or name scenarios.

Since this is your first time installing Horde, execute the script as follows:

# mysql –user=root \
=MySQL-root-password \
< mysql_create.sql

Now Horde is ready to be configured. cd into the horde/config directory and copy the original .dist configuration files to their proper names. To quickly copy the configuration files, execute the following within the config directories:

# for foo in *.dist; do cp $foo \
‘basename $foo .dist’; done

Keep the source .dist files handy, because you might make a mistake and need to fall back on the original file format. Perform this same action on IMP‘s configuration directory horde/ imp/config.

At this point, you should be able to see the login page at http://server-name/horde. However, you won’t be able to do much, as you haven’t set up an authentication mechanism. Before proceeding, take a moment and view the test file included with Horde to check if there are any glaring PHP or PEAR errors on your host. The test URL is http://server-name/horde/test.php. Fix any errors it finds.

Configuring Horde with IMP

Final configuration and deployment of Horde with IMP requires an authentication mechanism. In this example, the local, working IMAP server is used for authentication.

Since IMP is the package used for web mail services, Horde can use the authentication library already available in IMP. Open the file horde/config/registry.php with your favorite text editor and uncomment the following lines:

// $this->registry['auth']['login'] = ‘imp’;
// $this->registry['auth']['logout'] = ‘imp’;

This activates IMP’s authentication mechanism. Next, drop down to the parameter assignments for the IMP application and set status to active, as shown at the end of Listing One.

Listing One: Enabling IMP in Horde

$this->applications['imp'] = array(
‘fileroot’ => dirname(__FILE__) . ‘/../imp’,
‘webroot’ => $this->applications['horde']['webroot'] . ‘/imp’,
‘icon’ => $this->applications['horde']['webroot'] . ‘/imp/graphics/imp.gif’,
‘name’ => _(“Mail”),
‘allow_guests’ => false,
‘status’ => ‘active’

For this example, you won’t need to edit anything else in registry.php. However, if you install other Horde applications later, be sure to activate it within its respective area within the file. Just switch its status parameter to active.

Next, open the file horde/config/horde.php and skip down to the “Preference System Settings” section. Since the horde table MySQL has already been added to MySQL, edit this section to use it. Listing Two shows the lines that need to be adjusted to match your configuration. Take a thorough look through this file, as there might be other parameters you’d like to change, such as the site administrator’s email address and object caching parameters.

Listing Two: Editing Horde’s “Preference System Settings” in horde/config/horde.php

Select the sql driver by changing:

$conf['prefs']['driver'] = ‘none’;


$conf['prefs']['driver'] = ‘sql’;

Then set the appropriate parameters for the sql driver:

$conf['prefs']['params']['phptype'] = ‘mysql’;
$conf['prefs']['params']['hostspec'] = ‘localhost’;
$conf['prefs']['params']['username'] = ‘horde’;
$conf['prefs']['params']['password'] = ‘h@ckm3‘;
$conf['prefs']['params']['database'] = ‘horde’;
$conf['prefs']['params']['table'] = ‘horde_prefs’;

With IMP set for authentication, IMP needs to know how to contact the IMAP server. Open the file horde/imp/config/servers.php and edit the parameters for your IMAP server. The relevant section is shown in Listing Three. Again, use local hosts for your IMAP and SMTP servers as opposed to remote hosts, if possible.

Listing Three: Pointing Horde’s IMP to your IMAP server

$servers['imap'] = array(
‘name’ => ‘IMAP Server’,
‘server’ => ‘mail.server-name.com’,
‘protocol’ => ‘imap/notls’,
‘port’ => 143,
‘folders’ => ‘mail/’,
‘namespace’ => ”,
‘maildomain’ => ‘server-name.com’,
‘smtphost’ => ‘localhost’,
‘realm’ => ‘server-name.com’,
‘preferred’ => ”

The base install of Horde and IMP is now complete. Point your browser to http://server-name/horde and login with a known username and password for your IMAP server.

If you have problems logging in, make sure that you’ve set the appropriate parameters for your IMAP server. This is probably the most common problem when deploying Horde. Additional assistance can be found via mailing lists at http://www.horde.org/mail. There are also archives of mailing list discussions on MARC, located at http://marc.theaimsgroup.com. Mind mailing list etiquette: before posting to a mailing list for help, read the FAQ at http://www.horde.org/faq.

What’s Next?

Horde and its related projects are highly configurable and customizable applications. Each Horde application has its own set of templates and configuration files to allow you full control over the end-user experience or to place your end-users in full control.

For example, you can edit horde/imp/config/conf.php to use lspell or aspell as an interactive spellchecker, or to enable spam reporting, folder control, and even a sample mechanism for a quota system if you use the Cyrus or Courier IMAP daemons.

To give end-users a robust experience, install the Turba, Kronolith, and Nag projects. For more information on these and other stable IHorde project, visit http://www.horde.org/projects.php.

The Horde maintainers offer a public CVS repository. The bleeding edge versions available from CVS offer some outstanding new features, bug fixes, and global feature updates. In most cases, you can get the CVS updates working on your system without too much hassle.

The Horde project and its related applications are under constant development, and you might encounter features that are works-in-progress. If you wait a few days and update to the latest code from CVS, you’ll probably escape fixing the problems yourself. The features and improvements of Horde 3 are very tempting.

One caveat: the setup for the CVS versions of Horde and its ilk are vastly different from the examples used in this article, so it’s best to review the project’s documents and start reading the mailing list archives. Before attempting installation and configuration, make sure to study http://www.horde.org/source/versions.php.

Horde and its related webmail and groupware projects are currently deployed within major educational institutions, as well as large international corporations. Some of these systems support over 40,000 users.

With the ability to cluster Apache, PHP, IMAP, and SMTP servers, along with the sharing of Horde user sessions via a common MySQL database, a highly available, fault tolerant webmail system can be attained using purely open source applications.

There’s no doubt that Horde continues to be deployed, improved, and supported. It’s exceptional, free software that rivals any proprietary groupware/email system on the market today.

Michael Bordash is an open-source integration specialist at IPsoft, Inc. Michael can be reached at michael.bordash@ip-soft.net.

Comments are closed.