Mail Server Setup With Exim, MySQL, Cyrus-Imapd, Horde Webmail On Centos 5.1

Version 1.1
Author: Andrew Colin Kissa <andrew [at] topdog [dot] za [dot] net>


This how to describes the installation and configuration of a mail system on Centos 5.1 with selinux enabled for enhanced security. This system will be able to service HTTP, HTTPS, SMTP, TLS, SMTP-AUTH, IMAP, POP3 clients and is virtual enabled allowing more than one domain to be served from the system.

The webmail client imp will provide a feature rich interface with a webmail component, an address book, calendaring, and ability to reset passwords all with a highly configurable preference system to enable users to modify their look and feel as well as the operation of the interface.

The IMAP/POP3 system is the high performance cyrus-imapd system that runs as a sealed unit (mail users are not system users) and utilizes a high end/ performance back end for mail storage. The other cyrus-imapd features include, mail indexing for quick search operations using squat, a notification daemon that can be configured to notify via sms or email, sieve filtering system (auto response, mail filtering, notifications, filing), and built in quota system. This system will use pam_mysql via the SASL (saslauthd) mechanism to authenticate users against the Mysql database back end shared by all the components.

The exim system will be configured to enable users to relay mail using TLS secured SMTP-AUTH, using the same database backend that is shared by all the components. Address verification will take place using SQL queries to the mysql backend before any mail is accepted for delivery to the cyrus-imapd mail store. Anti-virus checks are integrated into this system with the use of clamav via a Unix domain socket. Spam checks are also run at smtp time via a socket connection to the spamd spamassasin system, messages scoring over 6 are automatically rejected with out being spooled to the system.

The mysql database will store the user authentication information encrypted using md5-hex as well as other information for the other webmail components.

This system is designed for high performance and security, cutting down on open ports and preferring to use unix domain sockets and running selinux in enforcing mode.

User account management takes place via the horde web interface allowing the admin easy access to add and remove accounts or to manage passwords, it is also possible to interact directly with the database table and make alterations there.


OS Installation Notes

For the purpose of keeping this howto precise i will not take you through the actually installation of the Centos 5.1 system i will assume that you have a bare bones install, a kickstart to help you get a bare bones install is can be downloaded here.

For this tutorial I will be using the static IP address and the hostname with a domain of, please feel free to make alterations to suite your environment. The working directory will be /usr/local/src all packages to be downloaded should be downloaded and extracted there.


Software Installation

Install Prerequisites

  • Update the system.
    yum update
  • Configure rpmforge repo
    rpm -Uhv
  • Disable the repo (such that base packages not overwritten) edit /etc/yum.d/rpmforge.repo and set the following option
    enabled = 0


Install Apache

yum install httpd php php-mysql php-xml php-imap php-mbstring php-mcrypt \
php-pecl-Fileinfo php-pear-DB php-pear-File php-pear-Log php-pear-Mail-Mime \
php-pear-Auth-SASL php-pear-Date php-pear-HTTP-Request php-pear-Mail php-pear-Net-Sieve \
php-pear-Net-Socket php-pear-Net-SMTP openssl mod_ssl -y


Install Exim

yum install exim system-switch-mail -y


Install Mysql

yum install mysql mysql-server -y


Install Horde

yum install horde imp-h3 ingo-h3 turba-h3 kronolith-h3 -y
tar xzvf passwd-h3-3.0.1.tar.gz -C /usr/share/horde
mv /usr/share/horde/passwd-h3-3.0.1 /usr/share/horde/passwd


Install cyrus-imapd

I will use the Invoca systems source rpm as it is more recent and support many features that the Centos build does not provide.

yum install db4-utils -y
rpm -Uvh
rpm -Uvh
rpm -Uvh


Install Pam_mysql

rpm -Uvh


Install ClamAV

yum --enablerepo=rpmforge install clamav clamav-db clamd -y


Install Spamassassin

yum install spamassassin -y
Share this page:

5 Comment(s)

Add comment

Please register in our forum first to comment.



The link ( for the kickstart returns permission denied.


My apologies, the link should work now.

By: nguyenlaman

  • Create a file admin.sql and add the following (modify the password to suite you)
USE horde;
REPLACE INTO horde_users (user_uid,user_pass)
    VALUES (
        '[email protected]',
        md5('[email protected]'),
  • Add user to database

mysql -p horde < admin.sql

Error , so i must add user to horde_users table by phpmyadmin but , still error

A fatal error has occurred

Could not connect to database for SQL SessionHandler.

Details have been logged for the administrator.



By: jacek

Good stuff, excellent tutorial!!!

By: Gilad Menachem

unfortently i cant finish this tutorial becuse i didnt find those component download

if some one got it or have i will glad for help