Today Jonathan asked me about configuring his system to pretend to be an email server.
The goals of this task were:
- Software under development would be able to use the local mail utilities, or use localhost as an smtp without any modifications
- Email sent via these programs would all be delivered to a static location instead of the destination address, to be read at another time
- No email would be relayed out to spam anyone else.
I have configured local email for development in the past, which is why Jonathan came to me with this. Immediately I decided to use postfix because it is easy to configure and use. Initially I looked at address masquerading or rewriting, but these solutions were overcomplicated and did not appear to solve all the problems.
Eventually I found a site explaining how to disable local delivery (the opposite of what we needed). The way to disable the local delivery was to comment out the 'local' configuration option in /etc/postfix/master.cf. Looking at the file it was clear that it mapped source to destination.
smtp unix - - - - - smtp relay unix - - - - - smtp local unix - n n - - local
The idea was simple, map 'smtp' and 'relay' to 'local'
smtp unix - - - - - local relay unix - - - - - local local unix - n n - - local
The results were exactly as desired. No email is delivered to the outside world, and all email is placed in /var/spool/postfix/active. According to Jonathan, his applications run seamlessly, completely unaware of this.
