last updated: Tue 12 May 1998

Installing qmail on Redhat Linux

Introduction

This document describes how to go about setting up qmail on a RedHat Linux system. It describes how to get and install two different qmail RPMs, and how your qmail system will be set up using these RPMS.
Summersoft RPM - David Summers <david@summersoft.fay.ar.us>

Use this RPM if you want a basic qmail setup.

Summary

Memphis RPM - Mate Wierdl <mw@moni.msci.memphis.edu>.

Use this RPM if you want a more fully-featured qmail setup.

Summary


1. Summersoft RPM

Built by David Summers <david@summersoft.fay.ar.us>

1.1 Build and install

If you are upgrading from a previous version of this rpm then it is suggested that you remove any old qmail users and groups, because the uids/gids now used are different from those used previously. See section 1.2 for the list of users and groups.

Download qmail-1.01-?.src.rpm from ftp://ftp.engr.uark.edu/pub/qmail.

These instructions and details were written for the qmail-1.01-9.rpm, but they should be pretty much compatible with future releases.

Type :

  # rpm -i qmail-1.01-9.src.rpm
  # rpm -bb /usr/src/redhat/SPECS/qmail-1.01-9.spec
You should now see the binary qmail RPM being built. Now install the binary RPM.
  # rpm -U /usr/src/redhat/RPMS/i386/qmail-1.01-9.i386.rpm
(Non Intel users should change the i386 above to the appropriate directory for their architecture).
Details of how qmail is being set up and installed are displayed.

Now move the qmail sources to a safe place, since there are many patches available on www.qmail.org that you may wish to apply.

  # mv /usr/src/redhat/BUILD/qmail-1.01 /usr/src/
The qmail sources will now be in /usr/src/qmail-1.01.

Now is a good time to look at the changelog section of the rpm spec, to see what has changed between versions, especially if you are using a version of the rpm later than the qmail-1.01-9.src.rpm.
To do this type:

  % more /usr/src/redhat/SPECS/qmail-1.01-?.spec
replacing ? with the version number of your qmail rpm. Look for the section that starts with %changelog.

1.2 Users/groups

You should see that the following lines were added to /etc/passwd:
  qmailp:*:86:80:qmail:/var/qmail:/bin/true
  qmaill:*:85:80:qmail:/var/qmail:/bin/true
  qmails:*:84:81:qmail:/var/qmail:/bin/true
  qmailr:*:83:81:qmail:/var/qmail:/bin/true
  qmailq:*:82:81:qmail:/var/qmail:/bin/true
  alias:*:81:80:qmail:/etc/qmail/alias:/bin/true
  qmaild:*:80:80:qmail:/var/qmail:/bin/true
You should see that the following lines were added to /etc/group:
  nofiles:*:80:
  qmail:*:81:
These are the various users/groups that qmail will use.

1.3 control files

Qmail control files are stored in /var/qmail/control. Type:
  # /var/qmail/bin/showctl | less
to see what your current qmail configuration is. Check that this information is correct. Read the qmail-control(5) man page for more information on each of the control files. I also suggest that you read the qmail-upgrade(7) and dot-qmail(5) man pages. Also read the qmail documentation project pages and www.qmail.org.

1.4 starting and stopping qmail

You can start qmail by running:
  # /etc/rc.d/init.d/qmail start
and you can stop it by running:
  # /etc/rc.d/init.d/qmail stop

1.5 running qmail-smtpd

You should see a line like the following at the end of /etc/inetd.conf
  #smtp   stream  tcp     nowait  qmaild  /usr/sbin/tcpd /var/qmail/bin/tcp-env /var/qmail/bin/qmail-smtpd
Remove the # at the beginning of the line. Now, you need to give inetd a HUP so that it recognises this change. Type:
  # killall -HUP inetd
Now type:
  # netstat -an | grep 25
You should see something like:
  tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
This means that qmail-smtpd is now listening on port 25, the mail port.

1.6 mailbox format

You now need to decide what type of mailbox format you are going to use. Read /usr/doc/qmail-1.01/INSTALL.mbox, and the maildir(5) man page. David Summers has kindly set it up so that you can specify the mailbox (and any other parameters to qmail-start) in /var/qmail/control/dot.qmail. By default this contains:
  ./Mailbox
which means that mail will get delivered to a file called Mailbox in each user's home directory. To use the Maildir mailbox format change this to:
  ./Maildir/
(Please remember the trailing /).

1.7 support for dot-forward files

Sometimes if you are converting from another Mail Transfer Agent (such as sendmail) you will need to keep support for .forward files. I don't suggest you do this if you don't have to, since .qmail files are much more powerful. If you do need .forward support then:

Download the dot-forward package from ftp://koobera.math.uic.edu/pub/software/. The most recent version is dot-forward-0.70. Untar this and read the INSTALL file for info on how to install it.

Then insert the following as the first line of /var/qmail/control/dot-qmail:

  |dot-forward .forward
So, your /var/qmail/control/dot-qmail should read something like:
  |dot-forward .forward
  ./Mailbox
or
  |dot-forward .forward
  ./Maildir/

1.8 Logs

The splogger program is used to make log entries in the syslog.

If you want to have all the mail logs go to a single file then add the following lines to /etc/syslog.conf:

  # Log all the mail messages in one place.
  mail.*                                                  /var/log/maillog
perhaps under the entry for /var/log/messages.

2. Memphis RPM

Built by Mate Wierdl <mw@moni.msci.memphis.edu>

2.1 Build and install

These instructions and details were written for the qmail-1.01-15ucspi.src.rpm, but they should be pretty much compatible with future releases.

The instructions are also really aimed at someone installing this qmail rpm for the first time. If you are upgrading, please take a look at the README file at:

ftp://moni.msci.memphis.edu/pub/qmail
The README file also gives information on using the rpm with NIS.

Download

from ftp://moni.msci.memphis.edu/pub/qmail/.

Type :

  # rpm --rebuild functions-2-1.src.rpm
  # rpm --rebuild daemontools-0.53-11.src.rpm
  # rpm --rebuild ucspi-tcp-0.80-12.src.rpm
  # rpm -U qmail-1.01-15ucspi.src.rpm
  # rpm -bb /usr/src/redhat/SPECS/qmail-1.01-ucspi.spec
You should see the binary RPMs being built. Now install all the binary RPMs.
  # rpm -U /usr/src/redhat/RPMS/i386/functions-2-1.i386.rpm
  # rpm -U /usr/src/redhat/RPMS/i386/daemontools-0.53-11.i386.rpm
  # rpm -U /usr/src/redhat/RPMS/i386/ucspi-tcp-0.80-12.i386.rpm
  # rpm -U /usr/src/redhat/RPMS/i386/qmail-1.01-15ucspi.i386.rpm
(Note that these RPMs have only been tested on i386 Intel.)

Now move the qmail sources to a safe place, since there are many patches available on www.qmail.org that you may wish to apply.

  # mv /usr/src/redhat/BUILD/qmail-1.01 /usr/src/
The qmail sources will now be in /usr/src/qmail-1.01.

Remove unnecessary stuff left over.

  # rm -f /usr/src/redhat/SOURCES/condredirect.diff
  # rm -f /usr/src/redhat/SOURCES/qmail*
  # rm -f /usr/src/redhat/RPMS/i386/functions-2-1.i386.rpm
  # rm -f /usr/src/redhat/RPMS/i386/daemontools-0.53-11.i386.rpm
  # rm -f /usr/src/redhat/RPMS/i386/ucspi-tcp-0.80-12.i386.rpm
  # rm -f /usr/src/redhat/RPMS/i386/qmail-1.01-15ucspi.i386.rpm

2.2 Users/groups

You should see that the following lines were added to /etc/passwd:
  alias:!!:80:80::/var/qmail/alias:/bin/true
  qmaild:!!:81:80::/var/qmail:/bin/true
  qmaill:!!:82:80::/var/qmail:/bin/true
  qmailp:!!:83:80::/var/qmail:/bin/true
  qmailq:!!:84:81::/var/qmail:/bin/true
  qmailr:!!:85:81::/var/qmail:/bin/true
  qmails:!!:86:81::/var/qmail:/bin/true
You should see that the following lines were added to /etc/group:
  nofiles:x:80:
  qmail:x:81:
These are the various users/groups that qmail will use.

2.3 control files

Qmail control files are stored in /var/qmail/control. Type:
  # /var/qmail/bin/showctl | less
to see what your current qmail configuration is. Check that this information is correct. Read the qmail-control(5) man page for more information on each of the control files. I also suggest that you read the qmail-upgrade(7) and dot-qmail(5) man pages. Also read the qmail documentation project pages and www.qmail.org.

2.4 Starting, stopping and signalling qmail

/etc/rc.d/init.d/qmail.init is used to start, stop and signal qmail.

You use it as follows:

  # /etc/rc.d/init.d/qmail.init param
where param is one of the commonly used paramterers described below.
start
start the qmail daemons
stop
terminates the qmail daemons
restart
terminates the qmail daemons, wait a bit, and then start them again.
(Useful for rereading control files other than locals and virtualdomains)
pause
temporarily stop the qmail daemons from running
cont
make the qmail daemons continue running
reload
makes qmail-send reload locals and virtualdomains
alrm
every message in the queue is rescheduled for immediate delivery.
term
causes the qmail daemons to stop once current delivery attempts have finished.
kill
kills the qmail-daemons
status
prints the status of the qmail-send process
help
prints a help message describing these parameters

2.5 Running qmail-smtpd

/etc/rc.d/init.d/qmail-smtpd.init is used to start, stop and signal qmail-smtpd. It takes the same command line parameters described for /etc/rc.d/init.d/qmail.init described above.

Since qmail is run under tcpserver and supervise you have a secure, reliable, and easy way to manage running it.

The number of concurrent connections to your smtp port is specified by the variable CONCURRENT in /etc/rc.d/init.d/qmail-smtpd.init. Initially this is set to 40, but this can be changed by editing the file. Look for:

  CONCURRENT=40              #number of concurrent connections
                             # (40 is the default of tcpserver)
near the beginning of the file.

The rules for who is allowed to connect to your smtp port are specified in /etc/tcprules.d/tcp.smtp. By default this file contains:

  127.0.0.1:allow,RELAYCLIENT=""
  your.host's.ip.number,RELAYCLIENT=""
This means that only local user's can use your mail port to relay mail. Read the tcprules(1) man page for information on setting up your rules.

2.6 Aliasempty options

The first paramter to qmail-start is the aliasempty option and it describes the default delivery instructions. These instructions are used when a local address does not have the appropriate .qmail file to handle it.

Usually aliasempty contains the name of the default mailbox, but it can also contain programs to run, such as the dot-forward program to handle .forward files under qmail.

Using this rpm, the aliasempty options are specified in the script /etc/rc.d/init.d/qmail.init. Look for the line that says:

  supervise $DIR qmail-start ./Mailbox accustamp qmail \
   | setuser $LOGUSER supervise $DIR-cyclog cyclog $LOGDIR &
If you want your default mailbox to be Mailbox in each users home directory then the default is correct.

If you want your default mailbox to be Maildir/ in each users home directory then change the ./Mailbox after qmail-start to ./Maildir/.

Note: remember the trailing / when using maildir.

2.6 Support for dot-forward files

Sometimes if you are converting from another Mail Transfer Agent (such as sendmail) you will need to keep support for .forward files. I don't suggest you do this if you don't have to, since .qmail files are much more powerful. If you do need .forward support then:

Download the dot-forward package from ftp://koobera.math.uic.edu/pub/software/. The most recent version is dot-forward-0.70. Untar this and read the INSTALL file for info on how to install it.

Then put it as the first aliasempty line.
So, your /etc/rc.d/init.d/qmail.init have something like:

  supervise $DIR qmail-start '|dot-forward .forward
./Mailbox' accustamp qmail \
   | setuser $LOGUSER supervise $DIR-cyclog cyclog $LOGDIR &
or
  supervise $DIR qmail-start '|dot-forward .forward
./Maildir/' accustamp qmail \
   | setuser $LOGUSER supervise $DIR-cyclog cyclog $LOGDIR &
Note that it is important that you make it look exactly like the above.

Logging

This rpm does not use the syslog for logging qmail activity. It uses the more reliable cyclog utility.

qmail-send's activity is logged in /var/log/qmail/. In this directory you will see a list of files like:

  -rw-r--r--   1 qmaill         50 May  4 14:23 @00000894284589
  -rw-r--r--   1 qmaill         50 May  4 14:24 @00000894284605
  -rw-r--r--   1 qmaill         50 May  4 14:25 @00000894284667
  -rw-r--r--   1 qmaill       8624 May  4 16:11 @00000894284713
  -rw-r--r--   1 qmaill       2732 May  4 16:48 @00000894292111
  -rw-r--r--   1 qmaill       1391 May  4 16:56 @00000894293336
  -rw-r--r--   1 qmaill        978 May  4 17:02 @00000894293781
  -rw-r--r--   1 qmaill       2703 May  4 17:18 @00000894294183
  -rw-r--r--   1 qmaill        515 May  4 19:16 @00000894301208
  -rw-r--r--   1 qmaill       5387 May  4 20:05 @00000894302177
The name of a log file is the TAI timestamp when the file was started. You can convert from TAI to your local date/time format using tailocal. See tailocal(1).

You can see what is happening in the current logfile by typing:

  % tail -f `ls -trc /var/log/qmail | tail -1`
It might be useful to put this in a script to avoid having to retype it.

Similarly, qmail-smtpd's activity is logged in /var/log/qmail-smtpd/.

For more information on cyclog, take a look at the cyclog(1) man page.


Acknowledgments

Mate Wierdl <mw@moni.msci.memphis.edu>
For his rpm.
For lots of helpful suggestions.
For proofreading the section on his rpm.
David Summers <david@summersoft.fay.ar.us>
For his rpm and looking at what I've written about it.


Keith Burdis <keith@rucus.ru.ac.za>