Intranet - Installing a mail server

February 2017

Introduction to installation

The most commonly used e-mail server in Linux is Sendmail; however, as it is very hard to configure, we will use Qmail, an alternative e-mail server, instead.

Qmail is made up of a group of programs that work with different UID/GIDs, in order to minimise intrusions.

Packages needed for installation

In order to install Qmail, the following packages are required:

  • functions-2-1.i386.rpm
  • daemontools-0.53-16-i386.rpm
  • ucspi-tcp-0.84-1.i386.rpm
  • qmail-1.03-14ucspi.i386.rpm
  • checkpassword-0.81-2.i386.rpm

They may be downloaded from the website

Installing Qmail

To install Qmail, you must first install all these RPM packages:

rpm -ivh functions-2-1.i386.rpm
rpm -ivh daemontools-0.53-16-i386.rpm
rpm -ivh ucspi-tcp-0.84-1.i386.rpm
rpm -ivh qmail-1.03-14ucspi.i386.rpm
rpm -ivh checkpassword-0.81-2.i386.rpm
Once these packages are installed, configuration files are created, as well as two user groups, seven new users, and the following directories:
  • /var/qmail: main directory
  • \_ alias/: for storing "special" accounts (like root)
  • \_ bin/: Qmail distribution binaires
  • \_ control/: configuration files
  • \_ defaultdelivery/: configuration files for mailbox formatting
  • \_ man/: pages in the manual
  • \_ doc/: documentation
  • \_ queue/: the queue file
  • \_ users/: address map (super-file of aliases)
The Qmail documentation is found in the directory /var/qmail/doc. To be able to use the pages in the Qmail manual, you have to manually add the path to them in the MANPATH variables using the following syntax:
export MANPATH=$MANPATH:/var/qmail/man

Redirecting the superuser's mail

With Qmail, for security reasons, the superuser (or root) cannot receive mail directly. His/her email must therefore be redirected to a special account, by editing the file .qmail-root (all files whose name begins with a full stop are hidden files) located in the directory /var/qmail/alias:

cd /var/qmail/alias
cat > .qmail-root
It is also possible to redirect mail for other users.

Choosing the mailbox format

With Qmail, you can choose a mailbox format, meaning the way that users' messages are stored. The format "Maildir" is used for storing users' messages directly into their work directory (hence the reason for creating Maildir in the skeleton).

Thus, in order to use this mailbox format, you must enter the following commands:

cd /var/defaultdelivery
cp -f mdir rc

Configuring Qmail

In order to be able to use Qmail, it still has to be configured, particularly the control files found in the directory /var/qmail/control :

  • me
    contains the name of the email server
  • defaultdomain
    contains the default domain name
  • locals
    contains all names/aliases on the mail server
  • rcpthosts
    contains the name of the domains authorized to use the mail server to send email
Here are the commands to enter to configure these files:
  • cd /var/qmail/control
  • cat > me
  • cat > me
  • cat > defaultdomain
  • cat > locals
  • cat > rcpthosts
The basic configuration of the server is finished, and now the mail server can be launched.

Launching services

The following commands are used to manually launch the services required by the email server:

/etc/rc.d/init.d/qmail.init start 
/etc/rc.d/init.d/qmail-smtpd.init start
/etc/rc.d/init.d/qmail-pop3d.init start
Here are the commands for automatically starting (and ending) these services each time the system reboots:
chkconfig --level 345 qmail on 
chkconfig --level 345 qmail-smtpd on
chkconfig --level 345 qmail-pop3d on
chkconfig --level 0126 qmail off
hkconfig --level 0126 qmail-smtpd off
chkconfig --level 0126 qmail-pop3d off

Michel Maudet


This document, titled "Intranet - Installing a mail server," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (