Create BCC of incoming and outgoing mails without knowing the users - Postfix



BCC to Boss Function - Postfix


Postfix provides three mechanisms:

    always_bcc = address
        Deliver a copy of all mail to the specified address.
    sender_bcc_maps = type:table
        Search the specified "type:table" lookup table with the envelope sender address for an automatic BCC address.
    recipient_bcc_maps = type:table
        Search the specified "type:table" lookup table with the envelope recipient address for an automatic BCC address.

These features are implemented in postfix 2.1 and later versions.

always_bcc

Add the following entry in /etc/postfix/main.cf to forward all mails in the server to administrator@example.com.

always_bcc = administrator@example.com



sender_bcc_maps and recipient_bcc_maps


You can setup these functions as follows.

[root@postfix ~]# touch /etc/postfix/sender_bcc
[root@postfix ~]# touch /etc/postfix/recipient_bcc

[root@postfix ~]# postmap sender_bcc
[root@postfix ~]# postmap recipient_bcc


Then, open /etc/postfix/main.cf and add the following lines in it.


sender_bcc_maps = hash:/etc/postfix/sender_bcc
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc


verify the following files are generated once the above steps are finished.

/etc/postfix/recipient_bcc.db
/etc/postfix/sender_bcc.db

You can add entries as like follows in sender_bcc and recipient_bcc. This will forward mails from user@domain.com to other@example.com.

[root@postfix ~]# cat /etc/postfix/sender_bcc
user@domain.com other@example.com

[root@postfix ~]# cat /etc/postfix/recipient_bcc
user@domain.com other@example.com


Finally reload postfix,

[root@postfix ~]# postfix reload




Reference:
http://www.postfix.org/ADDRESS_REWRITING_README.html

Leave a Reply