On Tue, Mar 22, 2022 at 08:38:39AM +0100, Arrigo Triulzi wrote:
> Unfortunately I have a slight complication: for a subset of valid
> email addresses I need to “bleed them” out to a different domain (and
> also archive all email but that is simply done with always_bcc).
>
> For example:
>
> [email protected] -> Exchange
> [email protected] -> [email protected] - not handled by Exchange
> [email protected] -> [email protected] - not handled by Exchange
If the number of exceptions is small, and comparatively static, and so
amenable to local configuration (indexed files not than remote databases),
then the simplest option is per-user transport mappings:
main.cf:
indexed = ${default_database_type}:${config_directory}/
transport_maps = ${indexed}transport
/etc/postfix/transport:
# order is not relevant
example.com smtp:[exchange.example.com]
[email protected] smtp:[lists.example.com]
[email protected] smtp:[it.example.com]
If there are many or frequently changed exceptions, and you want to use
LDAP or PosgreSQL, ... then my advice is to avoid per-user transport
tables (which are very latency sensitive at high message volume), and
perform two rewrites:
virtual:
[email protected] [email protected]
[email protected] [email protected]
generic:
[email protected] [email protected]
[email protected] [email protected]
transport:
# Drop [] if/when using MX records
lists.example.com [lists.example.com]
it.example.com [it.example.com]
.example.com [exchange.example.com]
example.com [exchange.example.com]
main.cf:
indexed = ${default_database_type}:${config_directory}/
virtual_alias_maps = ${indexed}virtual
smtp_generic_maps = ${indexed}generic
transport_maps = ${indexed}transport
Here virtual rewrite happens before transport lookup, and reverse
generic rewrite happens during delivery, so the recipient address seen
at the destination is unchanged.
--
Viktor.