Unlike some other mail systems, qmail uses separate daemons for incoming and outgoing mail. Incoming mail is handled primarily by qmail-smtpd. As discussed at the end of the previous chapter, local mail injected from MUAs on other computers also arrives by SMTP, and it’s important to distinguish the local from the incoming mail because they’re handled differently.
Chapter 4 discussed the basic setup of the SMTP daemon in /service/qmail-smtpd. The supervise daemon runs tcpserver, which listens for incoming connections, then runs qmail-smtpd to run the SMTP session and queue the received mail. The control file rcpthosts lists the domains for which it accepts mail. (If that file doesn’t exist, it accepts mail for all domains and can be an open relay, which spammers see as an open invitation to abuse.)
The normal SMTP setup consults a tcprules file that lists the IP addresses from which to accept and deny connections. The rules file is /var/qmail/rules/smtprules.txt, which is compiled into the binary /var/qmail/rules/smtprules.cdb that tcpserver consults.
In the FAQ distributed with qmail 1.03, question 5.5 describes the classic technique for cleaning up remotely injected mail. The smtprules.cdb file that tcpserver consults contains lines that set the RELAYCLIENT environment variable for hosts allowed to inject and relay mail. If RELAYCLIENT is set, ...