29Mar/110

Postfix for DEV setup – Catch all email and forward it to a specific address

Postfix Logo

On one hand we had a situation where DEV or QAS server accidentally sending email to various recipient. On the other hand we have developers and QA tester wanted to test and make sure that email functionality works. On top of all of these, the admin guys still want to receive their email coming from the server ie cron and logwatch email.

The following setup will configure postfix to accommodate all the requirements above. Postfix will prevent all outgoing email (black hole) . Instead of just dropping the email we capture and send a blind carbon copy (bcc) to a specific email address, leaving the “TO Address” intact. It will also allow selected mail to be routed to the original owner as well as the specific account receiving it.

Here is the config :

master.cf :

Add following at the end of master.cf . This will create a “discard” service.

discard   unix  -       n       n       -       -       pipe
user=nobody argv=/bin/cat /dev/null

main.cf :

Add the folllowing lines. All 3 lines are important. The first line is to configure BCC address. The second line is configure the email routing. The last line specifies that all domains are virtual domain for this postfix mail server.

recipient_bcc_maps = pcre:/etc/postfix/recipient_bcc
transport_maps = pcre:/etc/postfix/transport
virtual_alias_domains =

recipient_bcc:

# BCC all email to :
/^(.*)/       catchallemail@example.com

transport:

/catchallemail@example.com/    smtp:mailgateway.example.com
/administrator@example.com/	 smpt:mailgateway.example.com
/.*localdomain$/    local:
/.*/    discard:

Ideas developed from :
http://www.somerandomstuff.com/2009/07/09/howto-mail-blackhole/
http://www.wiredfool.com/2002/06/11/how-to-blackhole-email-server/ 

Posted by Rianto Wahyudi

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


9 × six =

No trackbacks yet.