Wednesday, May 11, 2011

How to send a copy of every email to a given email address in Postfix

SkyHi @ Wednesday, May 11, 2011
Recently, I wanted to send a copy of every email of particular person to a given email address using postfix. I was looking for solution in Postfix documents and i found simple way to do this using – Automatic BCC recipients.
To achieve this Postfix provides three mechanisms:

1. always_bcc = address
Deliver a copy of all mail to the specified address. If you want to deliver a copy of all emails to the specified email address then just you can add below config in main.cf and reload the postfix config. always_bcc=xyz@domain.com

2. sender_bcc_maps = type:table
Search the specified “type:table” lookup table with the envelope sender address for an automatic BCC address.

3. recipient_bcc_maps = type:table
Search the specified “type:table” lookup table with the envelope recipient address for an automatic BCC address.

1. create recipient_bcc mapping hash tables
# vi /etc/postfix/recipient_bcc

2. Add emails you want to apply this to:
#recipient_bcc mapping
abc@domain.com xyz@domain.com


3. Now you create the hash mapping database
# /usr/sbin/postmap /etc/postfix/recipient_bcc

4. Add this configuration in main.cf
# vi /etc/postfix/main.cf
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc


5. Reload the postfix configuration
#/etc/init.d/postfix reload

REFERENCES
http://www.techiepark.com/tutorials/how-to-send-a-copy-of-every-email-to-a-given-email-address-in-postfix/
http://www.postfix.org/ADDRESS_REWRITING_README.html#auto_bcc
http://www.freebsdonline.com/content/view/570/520/