On Sun, 5 Jan 2020 at 11:52, Thierry Fournier <thierry.fourn...@ozon.io>
wrote:

>            # intercept email for a competitor
>            /competitor/
> record=300,mx=mta1.local,prio=10,mx=mta2.local,prio=10
>
>            # remove mx1 which is a slow server for specific partner domain,
>            # keep only mx2 and mx3.
>            /^partner.com$/ record=300,mx=mx2.partner.com,prio=10,mx=
> mx3.partner.com,prio=10
>
>            # force not found response for the following domains. mail where
>            # were dropped with a bounce.
>            /^yahoo.com$/ notfound
>            /^gmail.com$/ notfound
>

Hi Thierry,

I was thinking I would have used the transport table combined with MX
records in local DNS.

Entries in the transport table:

competitor.com  relay:competitor.mx.mydomain.com
partner.com     relay:partner.mx.mydomain.com
yahoo.com       error:Mail for yahoo.com is not deliverable
gmail.com       error:Mail for gmail.com is not deliverable

Then add the overriding MX records in your own DNS:

$ORIGIN mx.mydomain.com.
$TTL 300
competitor      MX 10 mta1.local.
                MX 10 mta2.local.
partner         MX 10 mx2.partner.com.
                MX 10 mx3.partner.com.

With the above (matching "competitor.com") you would have this in main.cf:

transport_maps = hash:/etc/postfix/transport

But you could try type pcre instead of hash and use the lookup keys from
your examples. I have only used hash type transport maps myself, but the
documentation (e.g. postconf(5)) doesn't show any restrictions on table
type, so pcre should probably also work.

Would the above configuration achieve your goals?

Kind regards,
+ Kimmo

Reply via email to