In development environments (particularly in virtual machines) I like to be able to capture all email that is sent out. This is both handy because software that has embedded logic which emails production recipients can be caught, and also because emailing functionality can be tested without having to have a legitimate email recipient configured.
The following ultra-short configuration does just this, including a local aliases map which allows specific addresses to be redirected to different local users if desired:
alias_maps = hash:/etc/aliases inet_interfaces = loopback-only default_transport = local luser_relay = bjdean
Add this if size limits are getting in the way (who cares about the size, it's all local!):
# Allow larger emails through message_size_limit = 100720000 # no limit on mailbox sizes (note that postfix fails if the # message_size_limit is bigger than the default mailbox size limit) mailbox_size_limit = 0
Tracking Email Distribution
If a mail server is hosting a mailing list system or even when it hosts email redirections (to multiple recipients per redirection) it can be helpful to be able to track where and when an email ended up being distributed.
This script works (at the moment) only with postfix servers and produces a simple report for a given set of message IDs. It also allows for specific email recipient addresses to be checked (useful for example when finding if a particular recipient has received all emails for a mailing list): track_email_distribution.pl (GPLv3 license).
$ cat /var/log/mail.log | ./track_email_distribution.pl CasasASDw323sdfAx6_3GasAS232Kf9B_BuGjmYegXw@mail.example.net -addr email@example.com -addr firstname.lastname@example.org -addr email@example.com Tracking email with message id = CasasASDw323sdfAx6_3GasAS232Kf9B_BuGjmYegXw@mail.example.net .. email sent: Mar 16 09:27:13 .. 6 queue IDs: DEE79318031E, B0DCD318031E, B7FA831803F9, BBC5931803FC, CADE331804D6, D2B1B31804D8 .. 16 email recips: ZZZZZZZ@gmail.com, ZZZZZZZ@gmail.com, ZZZZZZZ@gmail.com, ZZZZZZZ@gmail.com, ZZZZZZZ@gmail.com, ZZZZZZZ@gmail.com, firstname.lastname@example.org, email@example.com, firstname.lastname@example.org, ZZZZZZZ@gmail.com, ZZZZZZZ@gmail.com, ZZZZZZZ@student.monash.edu, ZZZZZZZZ@example.com, ZZZZZZZ@student.monash.edu, ZZZZZZZ@gmail.com, email@example.com .. 2 check email addresses found: firstname.lastname@example.org, email@example.com