Re: sender based routing and transport_maps

2016-08-21 Thread Wietse Venema
Andrea Cappelli:
> What I want to accomplish is the following
> 
> 1) if sender is @domain1.com relay via smtp:[relay.domain1.com]
> 
> 2) otherwise round robin delivery from one of my IP via smtp (services
> configured in master.cf with differente ehlo and bound to different IP)
> (found on stack overflow, but now I can't retrieve the post)

Then don't use transport_maps.

Wietser

> I tried as follows
> 
> sender_dependent_default_transport_maps = hash:/etc/postfix/sender_relay,
> mysql:/etc/postfix/transport_roundrobin.cf

With Postfix 3.x, try:

sender_dependent_default_transport_maps =
hash:/etc/postfix/sender_relay
randmap:{one,two,three}

where one, two and three are transport:host (or transport:) that
should be used for non-matching senders.

sender_dependent_reelayhost_maps are an alternative, sinmce you
don't really need to override the transport, only the relayhost.

Wietse


Re: sender based routing and transport_maps

2016-08-21 Thread Andrea Cappelli
Il 21 ago 2016 1:20 AM, "Wietse Venema"  ha scritto:
> $ man 5 postconf | less '+/sender_dependent_default_transport_maps'
> ...
> This information is overruled with the transport(5) table.
> ...
>
> transport_maps has precedence over sender_dependent_default_transport_maps
> because transport_maps also has precedence over default_transport.
>

Thanks you Wietse for the clarification

> If you use sender-dependent routing, you can't use transport_maps.
> You can still use default_transport, relay_transport, local_transport
> and virtual_transport, for routing domains.

What I want to accomplish is the following

1) if sender is @domain1.com relay via smtp:[relay.domain1.com]

2) otherwise round robin delivery from one of my IP via smtp (services
configured in master.cf with differente ehlo and bound to different IP)
(found on stack overflow, but now I can't retrieve the post)

I tried as follows

sender_dependent_default_transport_maps = hash:/etc/postfix/sender_relay,
mysql:/etc/postfix/transport_roundrobin.cf

sender_relay

@domain1.comsmtp:[relay.domain1.com]:587 # (tried with and without
leading smtp)

transport_roundrobin.cf

query = SELECT transport from transport_roundrobin ORDER BY RAND() LIMIT 1

transport_roundrobin is a mysql table with a single column containing
service name as defined in master.cf (out1, out2, out3)

I think that when the sender is f...@domain1.com the hashmap should apply
and thus no query to mysql had to be performed, but the query is always
performed and the th delivery is chosen from the one's defined inside the
table

If I remove the mysql part (sender_dependent_default_transport_maps =
hash:/etc/postfix/sender_relay) mail from u...@domain1.com get relayed
correctly, other mail go to default smtp

Is my goal achievable and I'm worng at the configuration?

It's a bad idea?

Thanks
Andrea


Re: sender based routing and transport_maps

2016-08-20 Thread Wietse Venema
Andrea Cappelli:
> 2016-08-20 23:40 GMT+02:00 Andrea Cappelli :
> 
> > Hi All,
> > I have a postfix 2.9.6 setup on Ubuntu 12.04 which serve a bounch of local
> > mailbox and act as mail gateway with a tcp transport
> >
> > I want to use some external authenticated MTA based on sendere domain, so
> 
> Ok, I think I found my problem, my TCP service is called each time and
> always return a nexthop, so the sender based mechanism in postfix is never
> in action
> 
> Can someone please exaplain the order of lookup in transport(5)

$ man 5 postconf | less '+/sender_dependent_default_transport_maps'
...
This information is overruled with the transport(5) table.
...

transport_maps has precedence over sender_dependent_default_transport_maps
because transport_maps also has precedence over default_transport.

If you use sender-dependent routing, you can't use transport_maps.
You can still use default_transport, relay_transport, local_transport
and virtual_transport, for routing domains.

Wietse


Re: sender based routing and transport_maps

2016-08-20 Thread Andrea Cappelli
2016-08-20 23:40 GMT+02:00 Andrea Cappelli :

> Hi All,
> I have a postfix 2.9.6 setup on Ubuntu 12.04 which serve a bounch of local
> mailbox and act as mail gateway with a tcp transport
>
> I want to use some external authenticated MTA based on sendere domain, so
>

Ok, I think I found my problem, my TCP service is called each time and
always return a nexthop, so the sender based mechanism in postfix is never
in action

Can someone please exaplain the order of lookup in transport(5)

>From which I understood local_transport, virtual_transport and
relay_transport are checked (if the domain is configured in the appropriate
table or in mydestination for local), if no match is found the
default_transport apply

The lookup is done for the sender and for the recipient, right?

At which point lookups in transport_maps are applied?

Thank you

-- 
Andrea Cappelli