Tetsu Ushijima

How to set up a qmail SMTP service

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.


Setting up the service

  1. You will have to make three decisions:

  2. Create the service directory by running the qmail-smtpd-conf program:

              qmail-smtpd-conf qmaild qmaill /var/qmail/service/smtpd
  3. Change directory to the service directory:

              cd /var/qmail/service/smtpd
  4. 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.

  5. 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 and 192.168.1.*, add


    to tcp. You can do this by running the add-relayclient script:

              ./add-relayclient 192.168.1.
  6. Compile tcp into a binary format for tcpserver:


    (You have to run make in the service directory whenever you update tcp.)

  7. Tell svscan about the new service:

              ln -s /var/qmail/service/smtpd /service

    svscan will start the service within five seconds.

  8. 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

Testing the service

  1. 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.

  2. 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
  3. 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.

  4. Follow the instructions in TEST.receive (in /var/qmail/doc or in the qmail source directory).