I recently had a need to have a mail server capture all outgoing email and direct it to a single target account. My motivation for this was that I have a User Acceptance Testing server on which my software is tested before being deployed to production (this is in a Dev -> Test -> Prod controlled environment).
I had found an article on Eric London's blog, "
Configure your development server to deliver all mail locally". This is fine for local delivery, but I needed to have all email delivered to one off-server account (the group responsible for UAT).
The modifications I had to make to Postfix in my case were:
- This is a Debian box, so edit /etc/mailname to be a routable address so the corporate mail server (where I'm sending the email to) won't complain. I used the hostname of the Mac running the VMware instance;
- Add the lines to main.cf as Eric describes;
- Create the /etc/postfix/transport file as Eric describes, but insert the line target@example.com smtp:your.email.relay.example.com to allow off-server delivery;
- Run postmap and restart Postfix as described.
So main.cf looks like this:
…
transport_maps = hash:/etc/postfix/transport
always_bcc = target@example.com
and transport looks like this:
target@example.com smtp:your.email.relay.example.com
* discard:
Hope this helps someone!