Postfix Gateway with blind carbon copy Multiplicator

Abstract

Here is an exotic postfix gateway feature I did. It shows how to setup bcc copy with multiple recipients.

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:

example.com        OK

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:

alpha@example.com    OK
beta@example.com     OK
gamma@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:

bcc_duplicator_alpha@example.com   alpha@example.org alpha@example.net
bcc_duplicator_beta@example.com    beta@example.org beta@example.net

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:

alpha@example.com    bcc_duplicator_alpha@example.com
beta@example.com     bcc_duplicator_beta@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:

example.com    smtp:192.0.2.1

Note

You can't specify multiple recipients in the right hand side of the recipient_bcc_maps, so i had to go this way.

Robert Schetterer, 04. May 2015

   postfix