Postfix has terrific e-mail gateway capabilities, and yesterday I discovered a configuration option to select a mail transport based upon email address, rather than domain.

This is very desireable for me as it allows me to use my backup mail transfer servers to alias addresses within the domains they provide backup mx services for. This means if I want to alias an address to another off-network domain and the primary server is down, the backup mx agent can take can of it right there and then.

Now, onto the configuration specifics! Note: I use the postfix-cdb package for fast key-value pair hashing, and I also use relay_recipient_maps to specify the list of acceptable recipients on the gateway to prevent backscatter spam.

Postfix Transport Map Configuration for a Gateway Relay to Address Aliases Locally for Relayed Domains

Postfix main.cf: transport_maps

The key configuration option is transport_maps:

transport_maps = cdb:/etc/postfix/maps/transport

/etc/postfix/maps/transport

Example transport mapping:

support@example.com local:
example.com relay:[192.168.1.200]

In this example, support@example.com is treated as a local address, and Postfix will check the alias_maps configuration option, while the rest of the acceptable addresses for example.com will be relayed to 192.168.1.200.

At first I found it odd that Postfix did not require example.com to be specified in the mydestination directive, but just now I have concluded that transport_maps has the same effect, and it makes perfect sense to me.

For local aliasing, my configuration of Postfix is set in this way:

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

Example /etc/aliases

support:    external.email@gmail.com

I haven’t rolled this solution out to my backup MX servers, though I plan to do so once I test this solution out some more.