Setting up a WebMail server

From Section6wiki

Jump to: navigation, search

Contents

Web-based email using IMP

author: TBONIUS

IMP (Internet Messaging Program) is a PHP-based webmail application that uses Horde framework. It includes such features as spell-checking, attachments, address books, and multi-language support.

Requirements

  • Apache 1.3x or higher : /usr/ports/www/apache13
  • PHP 4.x or higher (configured with DOM-XML, FTP, GD, GDBM, gettext, IMAP)
  • MySQL Server 3.x or higher : /usr/ports/databases/mysql323-server
  • Turba 1.x or higher : /usr/ports/mail/turba

Pre-Configuration

There are a few things we need to configure ahead of time before we start installing IMP

Apache Configuration

Make sure your Apache webserver is configured to handle PHP by adjusting the following files:

/usr/local/etc/apache/httpd.conf

Under Section 1 : Global Environment, make sure the php module is loading

LoadModule php4_module        libexec/apache2/libphp4.so

Under Section2 : Main Server Configuration, make sure you can index php files

DirectoryIndex index.php index.html index.htm
/usr/local/etc/apache/mime.types

Make sure that Apache is configured to handle php mime types by adding the following lines:

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

Optionally we can make sure Apache is configured to use the SSL for secured transactions by loading the module in the httpd.conf

LoadModule ssl_module libexec/apache2/mod_ssl.so

IMAPd / Postfix Configuration

By default, IMAP-UW configures itself with IMAPS (secured IMAP), so if you wish use IMAP without SSL, you must configure the port by using the following option:

root@host # make WITHOUT_SSL="YES"

A working SMTP server is also essential for IMP to be practical in a production environment. We recommend using Postfix SMTP services. For information on configuring this service, please refer to the <a href="antispam.php">Postix Tutorial </a> page.

PHP Configuration

We also need to edit the /usr/local/etc/php.ini file and make sure these settings are uncommented and enabled:

file_uploads = On
short_open_tag = On
extension=imap.so

Installation of Horde

Horde is a bit tricky to install, given the fact there are a few options we can pass during the make process. Just running a make with configure Horde for Apache 1.3, but if we run make WITH_APACHE2="YES", then of course it will be configured for Apache 2.

Once installed, we need to edit /usr/local/www/data/horde/config/horde.php file and change the following settings:

In the "Horde General Settings" section:

$conf['use_ssl'] = 1;</tt> (Set this to 0 if you do not plan to use SSL)

In the "Horde Authentication" section:

$conf['auth']['driver'] = 'imap';
$conf['auth']['params']['dsn'] = '{localhost:143/imap}INBOX.';

In the "Preference System Settings" section:

$conf['prefs']['driver'] = 'session';

In the "Mailer" section:

$conf['mailer']['type'] = 'smtp';
$conf['mailer']['params'] = array('host' => 'localhost');

Then we need to edit the registry.php file and change the following settings:

In the "Handlers" section:

$this-&>registry['auth']['login'] = 'imp';
$this-&>registry['auth']['logout'] = 'imp';

Once these setting have been adjusted, we must change the permissions on the files in the config directory to protect the:

chmod 0640 /usr/local/www/data/horde/config/*

Installation of IMP

Much like the installation of the Horde framework, there are a couple of tricks to installing IMP. If we are running Apache 2.x, then we would make WITH_APACHE2="YES". If we do not want to use SSL, then we would pass the WITHOUT_SSL="YES" option. Also, if we do not wish to use Turba (for addressbook), then we would pass the WITHOUT_TURBA="YES option.

We can pass all these options on one line like in the following example:

make WITH_APACHE2="YES" WITHOUT_SSL="YES" WITHOUT_TURBA="YES"

Once IMP has been installed, we need to edit a couple of files to get it up and running:

We need to change the following lines in the /usr/local/www/horde/imp/config/conf.php file

In the "External Utilities" section:

$conf['utils']['spellchecker'] = 'aspell';

In the "Menu Settings" section: $conf['menu']['apps'] = array('turba');

In the "User Capabilities and Constraints" section

$conf['user']['allow_resume_all_in_drafts'] = true;
$conf['user']['select_sentmail_folder'] = true;

In the "Mail Server Settings" section:

$conf['server']['server_list'] = 'hidden';
$conf['server']['change_server'] = true;
$conf['server']['change_port'] = true;
$conf['server']['change_protocol'] = true;
$conf['server']['change_folders'] = true;

In the "Mailbox Settings" section:

$conf['mailbox']['from_link'] = 'compose';
$conf['mailbox']['show_attachments'] = true;

In the "Message Settings" section:

$conf['msg']['append_trailer'] = false;

At this point we can save the conf.php file and edit another file in the config directory called servers.php and make the following changes:

$servers['imap'] = array(
    'name' => 'IMAP Server',
    'server' => 'localhost',
    'protocol' => 'imap/notls',
    'port' => 143,
    'folders' => ,
    'namespace' => 'INBOX.',
    'maildomain' => 'example.com',
    'smtphost' => 'localhost',
    'realm' => 'example.com',
    'preferred' => 
);


Of course we would substitute example.com for our real domain name. If we compiled IMAP with SSL support then we would substitute the protocol and port settings for the proper options; imap/ssl and port 993. Also we need to comment out any other $server entries in this file, as we are only using IMAP (or IMAPS).

We also need to change the mode of the files in this directory to protect them:

chmod 0640 /usr/local/www/horde/imp/config/*

Afterwards, we can simply create a symbolic link from our web content directoy to the horde directory:

ln -s /usr/local/www/horde /usr/local/www/data/horde

Then we can restart the Apache Web Server and access the new IMP server

http://whatever_your_servername_is/horde

Configuring Turba

Coming soon...

Personal tools