Setting up IMP Webmail

General Information

When I first set up my mail server, I was faced with a dilemma — which webmail program should I use? I started out with SquirrelMail, but I soon installed vpopmail and needed a webmail client that could support virtual users. So, my next stop was NuralStorm, but it lacked some features I wanted. I had always heard about Horde’s webmail client, but I was always afraid of it because of it’s complexity. This guide aims to ease your mind about IMP and help you install it and get it running from a base system and an updated ports tree.

Requirements

  1. Local root access on the box or be able to su to root.
  2. A SSH client that supports ANSI colors such as puTTy or SecureCRT (if you aren’t on the box).
  3. Your favorite text editor (I like nano).
  4. A working mail server.

Installation

Web server

In order for a webmail system to actually be useful, we need to install Apache and MySQL. MySQL is used to store user preferences within Horde. If you want SSL support, just follow the Apache+SSL Guide for the Apache and MySQL installation.

# cd /usr/ports/www/apache13
# make install distclean
# cd /usr/ports/databases/mysql40-server
# make install distclean

With the new packaging of php4 and its extensions, we will let Horde install php4 and the necessary extensions for us.

Horde

Now we are going to install the Horde framework and all of its dependencies. This will install Horde, some pear stuff, and php4 with the necessary extensions. You can always add more extensions easily by installing /usr/ports/lang/php4-extensions.

# cd /usr/ports/www/horde
# make install distclean

Once it starts configuring the php4 installation, you will have to select whether you are using apache2 and if you want to use IPv6. Make your selections to continue. Once you’ve decided, so go take a break, see some daylight, and let the install do its thing.

IMP

It is finally time to install the Internet Messaging Program. This will install IMP (webmail) and Turba (addressbook).

# cd /usr/ports/mail/imp
# make install distclean

Configuration

Web server

Now that PHP is installed, we need to edit the apache config file (httpd.conf) to support PHP by adding the following lines after all the “LoadModule” lines.

# nano -w /usr/local/etc/apache/httpd.conf

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

You will also need to change the ServerName flag to your domain.tld in order for apache to actually work properly. You will also want to either create a virtualhost for your webmail or change the DocumentRoot as follows:

ServerName domain.tld
..
DocumentRoot "/usr/local/www/horde"
..

Now that Apache is configured, let’s start the daemon and the MySQL server.

# /usr/local/sbin/apachectl start
# /usr/local/etc/rc.d/mysql-server.sh start

MySQL

By default, MySQL’s root user comes with a blank password. This is not safe to keep so we need to set a password for the root user. You will want to login to MySQL, then set the password, and finally exit like this:

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3 to server version: 4.0.20

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> SET PASSWORD FOR root = PASSWORD('secret');
Query OK, 0 rows affected (0.04 sec)

mysql> quit
Bye

In order for Horde to interact with MySQL, we need to first construct the database structure for it. Fortunately, the Horde package gave us the script for it. We’d better edit it first to set the username and password for Horde to use.

# cd /usr/local/www/horde/scripts/db
# nano -w mysql_create.sql

REPLACE INTO user (host, user, password)
    VALUES (
        'localhost',
        'horde',
  -- IMPORTANT: Change this password!
        PASSWORD('horde')
    );

Got that username and password changed? Good. Now let’s feed the script into MySQL.

# mysql -u root -p < mysql_create.sql

Horde

Horde installs itself in /usr/local/www/horde/ and all additional programs get installed recursively. Such as, IMP gets installed in /usr/local/www/horde/imp/ and so on.

Now it is time to take a look into the configuration files of Horde.

# cd /usr/local/www/horde/config

You will see there are a few files that you could edit. But, you only need to edit horde.php as it contains the connection information. For example, you edit your MySQL connection information here and how you want your users to authenticate when logging it - whether imap, ftp, smb, etc. Feel free to look at the other files and tune them if you would like. I cannot go into great depth of each file and setting, especially since the config files are well documented.

IMP

# cd /usr/local/www/horde/config

This is the directory you should get comfortable with because there is more to change in these files than in horde's config directory. You need to set the config for your server types that you want to connect to in servers.php. You need to go through conf.php to configure how you want your mail handled. For instance, you can append a trailer to every outbound e-mail. You can also restrict users to login to one server and protocol, or you can leave it open for them to select. You can choose to have Horde log in the MySQL database, or log in /var/log/horde.log. By editing motd.php, you can put up your own message on the login screen.

After editing the config files, you should now have your webmail system installed and working. Point your favorite broswer to http://domain.tld/ and you should be faced with a login screen. If you are unable to log in, check your config files to make sure they are connecting to the right server. You can also view the Horde System Capabilities Test page at http://domain.tld/horde/imp/test.php and try to log in. It should either be a success or display the error.

Now that your webmail is working, you can add additional components to it as IMP is only one program for the Horde framework. There is a whole suite of Horde projects for you to check out.

Speak Your Mind

*