A qmail SMTP service handles incomming SMTP connections. It runs qmail-smtpd under tcpserver and uses multilog to store log messages. Both tcpserver and multilog are supervised.
Install daemontools 0.70 or above. The following instructions assume that your boot scripts are already running svscan in a /service directory.
Install ucspi-tcp 0.86 or above.
Install and configure qmail 1.03. Installing qmail means creating the /var/qmail directory tree. Configuring qmail means setting up some basic control files in /var/qmail/control, setting up some basic aliases in /var/qmail/alias, and setting up /var/qmail/rc. If you have followed the instructions in INSTALL from the beginning through step 8, you must have done all these things.
The following instructions assume that any process is currently not listening on the TCP port 25, the standard SMTP port. If some process is currently listening on the TCP port 25, you have to stop that process or have that process not listen on the port before going any further. Here is a (probably incomplete) check list:
If you are running sendmail, follow the instructions in REMOVE.sendmail (in /var/qmail/doc or in the qmail source directory) to remove sendmail.
If you are running inetd and /etc/inetd.conf contains a line that starts with smtp, comment out that line and give inetd a HUP signal.
If you are running qmail-smtpd under tcpserver, give that tcpserver a TERM signal and comment out the tcpserver invocation in your system boot scripts.
You should have already set up a qmail delivery service. If you haven't, mail messages received via SMTP will be left in the queue without being delivered anywhere.
You will have to make three decisions:
The qmail daemon account name, normally qmaild. The tcpserver program and the qmail-smtpd program run under this account. If this account does not exist, create it now.
The qmail log account name, normally qmaill. Logging programs run under this account. If this account does not exist, create it now.
The qmail SMTP service directory, normally /var/qmail/service/smtpd. This is where logs and a few configuration files are stored.
Create the service directory by running the qmail-smtpd-conf program:
qmail-smtpd-conf qmaild qmaill /var/qmail/service/smtpd
Change directory to the service directory:
cd /var/qmail/service/smtpd
Optionally, if you have already set up /etc/tcp.smtp for tcpserver and want to preserve the rules, copy /etc/tcp.smtp to tcp:
cp /etc/tcp.smtp tcp
Warning: /etc/tcp.smtp and /etc/tcp.stmp.cdb will no longer be used. Instead, tcp and tcp.cdb in the service directory will be used. Sorry for the incompatibility with the official qmail documentation.
Optionally, if you want to allow relaying from selected clients through the service, add lines to tcp allowing connections and setting the RELAYCLIENT environment variable for the selected clients. For example, if you want to allow relaying from 127.0.0.1 and 192.168.1.*, add
127.0.0.1:allow,RELAYCLIENT="" 192.168.1.:allow,RELAYCLIENT=""
to tcp. You can do this by running the add-relayclient script:
./add-relayclient 127.0.0.1 192.168.1.
Compile tcp into a binary format for tcpserver:
make
(You have to run make in the service directory whenever you update tcp.)
Tell svscan about the new service:
ln -s /var/qmail/service/smtpd /service
svscan will start the service within five seconds.
Optionally, if you want compatibility with the official qmail documentation, create a symbolic link /var/log/smtpd that points to the actual log directory:
cd /var/log test -d smtpd && mv smtpd smtpd.bak ln -s /var/qmail/service/smtpd/log/main smtpd
Check the service status:
svstat /service/smtpd /service/smtpd/log
The output should look something like:
/service/smtpd: up (pid 6345) 6 seconds /service/smtpd/log: up (pid 6347) 6 seconds
Run svstat several times and make sure that the process IDs shown do not change.
Check the log messages:
tail -f /service/smtpd/log/main/current | tai64nlocal
The directory /service/smtpd/log/main contains log files to which tcpserver (and possibly its children) stores the log messages. The output should look something like:
tcpserver: status: 0/40
Use ps to browse the process tree. It should contain the following portion:
svscan /service supervise smtpd /usr/local/bin/tcpserver -vDUHR -lyour.host -xtcp.cdb -- 0 25 ... supervise log multilog t ./main
Two new supervise processes should have been added as svscan's children, one for tcpserver (running as qmaild) and the other for multilog (running as qmaill). The process IDs of tcpserver and multilog should match with svstat's output. All these processes should be idle at this time.
Follow the instructions in TEST.receive (in /var/qmail/doc or in the qmail source directory).