Print View

Setting up IMP Webmail
Updated: 06/05/2005


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"
..
<Directory "/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: <Just hit enter>
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.

Author: Jon LaBass
jon at bsdguides dot org

Find this guide useful?
Support the author:


17 Comments

Posted by ex279 on August 11, 2005 at 2:05:53 pm EEST

When I initially setup my server I used the "Apache+SSL, PHP, and MySQL" Guide on this site to install PHP.  It installs mod_php4.  However, when I try to setup horde2 by excuting these commands, I get errors concerning the php type.

cd /usr/ports/www/horde2
make install distclean

If you plan to install IMP, it is better to configure
PHP with IMAP / IMAP-SSL, OpenLDAP, OpenSSL, mcrypt, XML,
FTP, gettext, zlib, MCAL and a database (like MySQL or
PostgreSQL).
For Japanese language, please enable mbstring.

===>  Vulnerability check disabled
===>  Extracting for horde-2.2.5_1
>> Checksum OK for horde-2.2.5.tar.gz.
===>  Patching for horde-2.2.5_1
===>  Applying FreeBSD patches for horde-2.2.5_1
===>  Configuring for horde-2.2.5_1
===>  Installing for horde-2.2.5_1
===>   horde-2.2.5_1 depends on file: /usr/local/share/pear/Date.php - not found
===>    Verifying install for /usr/local/share/pear/Date.php in /usr/ports/devel/pear-Date
===>   pear-Date-1.4.3 depends on file: /usr/local/share/pear/PEAR.php - not found
===>    Verifying install for /usr/local/share/pear/PEAR.php in /usr/ports/devel/pear-PEAR
===>   pear-PEAR-1.3.1 depends on file: /usr/local/share/pear/Archive/Tar.php - not found
===>    Verifying install for /usr/local/share/pear/Archive/Tar.php in /usr/ports/archivers/pear-Archive_Tar
===>  Installing for pear-Archive_Tar-1.2
===>   pear-Archive_Tar-1.2 depends on executable: pear - not found

===>    Verifying install for pear in /usr/ports/devel/php4-pear
This port requires the CLI or the CGI version of PHP, but you have
already installed a conflicting PHP port without them.
*** Error code 1

Stop in /usr/ports/devel/php4-pear.
*** Error code 1

Stop in /usr/ports/archivers/pear-Archive_Tar.
*** Error code 1

Stop in /usr/ports/devel/pear-PEAR.
*** Error code 1

Stop in /usr/ports/devel/pear-Date.
*** Error code 1

Stop in /usr/ports/www/horde2.



Are there any suggestions on how to update php, for horde to work, withough affecting what I have already done?


Posted by Jon on August 11, 2005 at 2:05:53 pm EEST

Horde requires the PHP command line interface to work with pear.  mod_php4 is only the web module so pear will not work with it.  What you will want to do is:

cd /usr/ports/www/mod_php4
make deinstall clean
cd /usr/ports/lang/php4
make install clean

That will remove the web module and install PHP with the CLI <i>and</i> the web module.  All of your php extensions and configuration files should still be intact.

I will edit the guide to make a note of this issue.


Posted by ex279 on August 11, 2005 at 2:05:53 pm EEST

The make deinstall worked.  Thanks!


Posted by fakrul on August 11, 2005 at 2:05:53 pm EEST

I run the test.php with the following option:
Server: localhost
Protocol: imap
Port: 143
User: username
Password: *******

But it shows the following error:

server="localhost" user="username" mailbox="{localhost:143/imap}INBOX"

array(1) {
  [0]=>
  string(64) "Connection failed to localhost.mydomain.com,143: Connection refused"
}

If I check the netstat -na than it there isn't any 143 port open. But it i check the "/usr/local/www/horde/imp/config/servers.php" file there i find that  imap has por 993.
'port' => 993
Do I change the port to 143?? Or how do I enable IMAP. I install imp3 as you instructed.

Thanks


Posted by fakrul on August 11, 2005 at 2:05:53 pm EEST

Now I am getting 143 but horde shows the following error

server="localhost" user="fakrul" mailbox="{localhost:143/imap}INBOX"

array(1) {
  [0]=>
  string(55) "Server disables LOGIN, no recognized SASL authenticator"
}


Posted by Jon on August 11, 2005 at 2:05:53 pm EEST

The problem you are running into is that port 993 is for the secure IMAP and 143 is for regular IMAP.  If you run a secure IMAP daemon, then you will need to have the following set in /usr/local/www/horde/imp/config/servers.php:

    'protocol' => 'imap/ssl/novalidate-cert',
    'port' => 993,

If you are running a regular IMAP daemon, then you will need to have the following set in servers.php:

    'protocol' => 'imap/notls',
    'port' => 143,


Posted by dan_simons on August 11, 2005 at 2:05:53 pm EEST

I can't get logged in to Horde, not sure why.

I ran the /horde/imp/test.php and it seems to work.

server="localhost" user="dan@hardrocksociety.com" mailbox="{localhost:143/imap}INBOX"
INBOX has 0 messages (0 new 0 recent)

I'm sure it just some things not set right in the config. Any ideas i can try?

Thanks,
Dan


Posted by dan_simons on August 11, 2005 at 2:05:53 pm EEST

I now am able to log in, actually sent mail from horde to another account. Its cool. Nothing is being received though. Does something have to change for the INBOX?


Posted by Jon on August 11, 2005 at 2:05:53 pm EEST

How is your IMAP section of /usr/local/www/horde/imp/config.php set up?  That file determines which IMAP dir to look at.


Posted by dan_simons on August 11, 2005 at 2:05:53 pm EEST

I have mail working now. I am getting this error when logging in. If I refresh the page twice, i then can get into horde. Any ideas???

A fatal error has occurred:

DB Error: connect failed

[line 108 of /usr/local/www/horde/lib/Prefs/sql.php]

Details have been logged for the administrator.


Posted by Jon on August 11, 2005 at 2:05:53 pm EEST

You need to set the MySQL username and password to use in horde.  The file to edit this would be /usr/local/www/horde/config/horde.php and somewhere around line 173.  This file sets where to read/write preferences and the default is to use MySQL so you have to make sure horde has the right configuration information set in horde.php.


Posted by jdeguzman on August 11, 2005 at 2:05:53 pm EEST

As i try to install IMP Webmail i couldn't seem to find the horde2 folder and imp3 folder from the ports tree? I have already updated the ports tree...Any ideas? Thanks!

Jovi


Posted by Jon on August 11, 2005 at 2:05:53 pm EEST

The horde and imp ports have been updated to reside only in /usr/ports/www/horde and /usr/ports/mail/imp.  The guide has been updated to reflect these changes.


Posted by kingedgar on August 11, 2005 at 2:05:53 pm EEST

Any replacement for php4-domxml in php5? I would like to use this with php5 but when I go to install horde i get this --


# make install distclean
Unknown extension domxml for PHP 5.
*** Error code 1

Stop in /usr/ports/www/horde.

Any help is greatly appriciated!


Posted by nienithaur on August 11, 2005 at 2:05:53 pm EEST

I have the exact same problem! Actually I registered just to say that... Deinstalling the dom and xml extensions didn't seam to help.. Though I'm not sure if I did it all that properly. As kingedgar I would be extremely grateful for any help on this matter!


Posted by nienithaur on August 11, 2005 at 2:05:53 pm EEST

Thanks to zparta at www.sweclockers.com (thank you again!) I have managed to now solved this problem! Just add -DWITH_PHP5 when installing the port (make -DWITH_PHP5 install) and it works like a charm.


Posted by Stegnation on August 11, 2005 at 2:05:53 pm EEST

Thanks! -DWITH_PHP5 worked perfectly!


Copyright 2003 - 2008 BSD Guides.  All rights reserved.

About | Terms of Use | Privacy | Contact