postfix transport with smarthost By dropbearAugust 8, 2013Networks Dear lazyyweb, Has anyone got a way for postfix to use a transport map such that it sends email to the given MX host for some specified domains then default to a smarthost for the remainder? The logic would be: IF domain in (‘example.net’, ‘foo.bar’,etc etc) THEN use the relevant MX host ELSE send to smarthost.isp.net i can use a transport map to send from specific domains to specific hosts, eg @domain.com goes to otherisp.net mailserver but not to just use domain.com’s MX hosts
Is it not enough to simply put that in a transport table (null nexthop, use the recipient domain, cf. transport(5)):
Otherwise, you can use no relayhost but instead use a transport table that uses your relay as a nexthop for all except some domains:
This is almost the same as an example that is provided in transport(5).
This worked! You cannot use relayhost because the transport map is no longer used and everything goes via it. However a wildcard does work with specified domains using their MX hosts and everything else going via relay host. Thanks.
Please read the postfix docs, they’re there for a reason.
Any entry in the transport map will be resolved for its MX addresses if specified without , or resolved for its A addresses if specified within .
Manpage transport(8) even shows how to do what you want in the examples.
Are you possibly using the [host] form? As transport(5) says, [host] vs. host disables MX lookups:
“The interpretation of the nexthop field is transport dependent. In the case of SMTP, specify a service on a non-default port as host:service, and disable MX (mail exchanger) DNS lookups with [host] or [host]:port. The  form is required when you specify an IP address instead of a hostname.”
Its easy. As you say you have to use the transports map. If you put a domain/host as the transport, postfix will query for it’s mx record by default. In fact, if you want to prevent this behaviour you have to enter the transport between square brackets, as in [myrelay.example.com]
Sounds like you want to use something like this:
transport_maps = hash:/etc/postfix/transport
relayhost = default.relay.com
relayhost trumps the transport map so everything goes via the relay.
Craig Small: postfix transport with smarthost: Dear lazyyweb,
Has anyone got a way for postfix to use a transp… http://t.co/RPA6h7wbiJ
Does it need to be done with a transport map? It sounds like using sender_dependent_relayhost_maps would accomplish what you are looking for (just set relayhost to the default smarthost and add each @domain with a different smarthost to the relayhost map).
$ man 5 transport
In order to deliver internal mail directly, while using a mail relay for all other mail, specify a null entry for internal destinations (do not change the delivery transport or the nexthop information) and specify a wildcard for all other destinations.
oh ok, i didnt realse wildcards like that work, or the ultimate wildcard
In the transport map, a value of “:” says to use the default routing, which means to use the MX records. Example from my transport map:
@SeeSmall2 Yes, dont use relayhost and use null actions in transport with a wildcard. dont forget your own destinations