transport maps lookup order

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

transport maps lookup order

Lists Nethead

postfix-3.2.2

Case in question:

transport_maps = hash:/usr/local/etc/postfix/transport,  
ldap:/usr/local/etc/postfix/ldap-transport.cf

I had the (possibly erroneous) belief that Postfix searches the tables  
in the order given in main.cf and that the domain part is sufficient.
What we wanted to accomplish is, in the hash table which is the first  
entry above

example.com   smtp:[a.host.somwhere]

postmap -q example.com returns smtp:[a.host.somwhere] but nevertheless  
the mail is *not* sent to "a.host.somwhere"


If one enters an email address instead, it works

[hidden email]   smtp:[a.host.somwhere]

So the question is, how can we set up the transport maps in a hash  
file so that all mail for users in the example.com domain gets sent to  
smtp:[a.host.somwhere] instead of the default entry which is below in  
the hash file.

I have the feeling that Postfix actually combines the tables and then  
stops at the first match. Anyways, if someone could shed a little  
light where I'm going wrong please.

//per

Reply | Threaded
Open this post in threaded view
|

Re: transport maps lookup order

Wietse Venema
Lists Nethead:

>
> postfix-3.2.2
>
> Case in question:
>
> transport_maps = hash:/usr/local/etc/postfix/transport,  
> ldap:/usr/local/etc/postfix/ldap-transport.cf
>
> I had the (possibly erroneous) belief that Postfix searches the tables  
> in the order given in main.cf and that the domain part is sufficient.
> What we wanted to accomplish is, in the hash table which is the first  
> entry above
>
> example.com   smtp:[a.host.somwhere]

It searches both tables for [hidden email] (email address) in the
order given in main.cf, then it searches both tables for example.com
(domain only) in the order given in main.cf.

> So the question is, how can we set up the transport maps in a hash  
> file so that all mail for users in the example.com domain gets sent to  
> smtp:[a.host.somwhere] instead of the default entry which is below in  
> the hash file.

Here is a trick to make the [hidden email] match the first table:

transport_maps =
    pcre:/usr/local/etc/postfix/transport.pcre
    ldap:/usr/local/etc/postfix/ldap-transport.cf

/usr/local/etc/postfix/transport.pcre
    /@example\.com$/ smtp:[a.host.somwhere]

With this, Postfix will not send the 'domain only' queries to the
PCRE table, but it would still send them to the LDAP table.

        Wietse