Part 4. Set up the automatic creation of hidden copies of messages.

The list of articles cycle

Sometimes it is necessary to create copies of messages and send them to another address. For this purpose, Postfix has a mechanism for creating hidden copies (bcc – blind carbon copy)

You can create these copies based on the sender or recipient addresses. To do this, you can use the sender_bcc_maps or recipient_bcc_maps parameters in the main.cf file.

The format of these lines will be the following

sender_bcc_maps = type:table

recipient_bcc_maps = type:table

 

For example, we need to send copies of all the letters from This email address is being protected from spambots. You need JavaScript enabled to view it. and to This email address is being protected from spambots. You need JavaScript enabled to view it. to the mail address This email address is being protected from spambots. You need JavaScript enabled to view it..

 

Let’s create files bcc_recipient and bcc_sender. We will write in them the same line

This email address is being protected from spambots. You need JavaScript enabled to view it. This email address is being protected from spambots. You need JavaScript enabled to view it.

 

Let’s create an indexed maps from these files:

# postmap bcc_recipient

# postmap bcc_sender

 

 

Add 2 lines to file main.cf

sender_bcc_maps = hash:/etc/postfix/bcc_sender

recipient_bcc_maps = hash:/etc/postfix/bcc_recipient

 

and now restart Postfix

service postfix restart

 

After that all messages from and to This email address is being protected from spambots. You need JavaScript enabled to view it. will be copied to the address This email address is being protected from spambots. You need JavaScript enabled to view it.

 

If there is a need to copy all the letters not from a specific address, but from a specific sender's domain then you must use another type of tablesregexp.

Make a copies of all emails that are sent from the test.local domain. We will send the copies to the same addressThis email address is being protected from spambots. You need JavaScript enabled to view it.. To do this, create a file reg_bcc_sender and write to it:

/test\.local/ This email address is being protected from spambots. You need JavaScript enabled to view it.

 

Once we have already described the sender_bcc_maps parameter and we do not need to describe it again. Just complete his description . Bring line to form:

sender_bcc_maps = hash:/etc/postfix/bcc_sender regexp:/etc/postfix/reg_bcc_sender

And now restart the Postfix

service postfix restart

 

Now, in addition to the previous settings for the hidden copies, all the messages from any address of the test.local domain will also be copied.

 

The list of articles cycle

You can buy the book

"Mail server based on Postfix,

Dovecot and RoundCube"

in electronic form in the store

ХinХii