Here is an exotic Postfix gateway feature I did. It shows how to setup bcc copy with multiple recipients, while sending to an internal mailserver via a smtp transport.
Some advanced mail admins might wonder about the following lines, so here is the short story what real world scenario was solved with it.
First Postfix was choosen as a typical excellent antispam/antivirus gateway for one internal mailsystem with one maildomain. Over time the customer company absorbed many other companies and renamed them to departments with similar maildomain names leaving existing mailservers at their outside offices in action as a temp solution. Emails to their main maildomain should be passed to their head quarter and cloned to outside departments. So traveling mailusers should have their mails in every office. I only show the clone part here.
Building the multiplicator
Absolutely usual at gateways first declare which domains are allowed in main.cf:
relay_domains = hash:/etc/postfix/relay_domains
In this example relay_domains contains the following domain:
Then declare allowed email addresses using relay_recipients in main.cf:
relay_recipient_maps = hash:/etc/postfix/relay_recipients
The relay_recipients table contains the following entries:
email@example.com OK firstname.lastname@example.org OK email@example.com OK
Now here's the trick. Put these recipients into a virtual_alias' map. First tell Postfix about the map in `main.cf:
virtual_alias_maps = hash:/etc/postfix/virtual_alias
The recipients in a virtual_alias map are:
firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com
Now tell Postfix to BDD to the virtual aliases. Again tell Postfix about the map in main.cf:
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc
Then fill the map with re-routings to the virtual aliases:
firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com
Finally create the transport towards the internal mailserver in main.cf:
transport_maps = hash:/etc/postfix/transport
My example map specifies the following routing:
You can't specify multiple recipients in the right hand side of the recipient_bcc_maps, so i had to go this way.