2016/07/03: postqmail

postfix is a well-maintained MTA that allows lot of flexibility on the gateway. On the other hand, qmail allows a lot of flexibility to control the mail delivery. So, why not try to combine both?

There are two things to do. On the one hand, you need to implement a qmail-local(8)—compatible delivery routine that uses postfix's mechanism to requeue a mail. Or, at least, you should be aware of where you deviate from qmail's specifications (not everyone likes seekable stdin) and what the consequences are. Also consider carefully which assumptions you make and how you handle errors (like broken pipes).

On the other hand, you need to configure postfix correctly. qmail uses an abstract mapping from email-addresses to users delivering the mails whereas postfix by default is backwards compatible till the old "user@host" format. So, the idea behind one way to configure postfix is to have mydestination a single domain, say call it user.example.local, not reachable from the outside, that corresponds to the Unix users on the local system. (The non-reachability can be achieved by setting smtpd_recipient_restrictions appropriately.) All actual mail domains are configured via virtual_alias_maps which, via a tcpmap, map email addresses to the users to handle them; the information which email-address the mail is for can still be found in the ORIGINAL_RECEIPTIENT environment variable when the delivery agent for that user is called. A tcpmap means that at some tcp endpoint (here you most probably want to use a designated port on the loopback device) postfix will ask for an email address and gets told if the email exists and where to deliver it to (i.e., where in our user.example.local mail domain). This service is the one that reads qmail's assign file and is most likely started by some form of inted super server. A similar service will provide the tcpmap for the virual_alias_domains which tells postfix which domains are the virtual domains to care about; this service will read qmail's virtualdomains file. Additionally, you have to tell postfix not to look at email addresses at all (like stripping "extensions" or interpreting "@" or "!") and make sure external hosts cannot send mail to your user-land local domain (say example.local).

This is indeed a bit of configuration, involving several services. So our approach (available at git://git.linta.de/isilmar/postqmail) also generates a puppet manifest site.pp to get started from a sensible configuration.



Cross-referenced by: