Postfix and multiple smarthosts

2008-12-31 Thread Andrew Hodgson
Hi,

I am trying to find the answer whether Postfix will support multiple
smarthosts - i.e, sending to specific smarthosts, and if one fails, it
will try to send to the next one in the list, or will just use any
smart host in the list without issue?

I have found several examples of using smart host routing based on
destination domain, but this is not what I want to do.

Thanks.
Andrew.



RE: Postfix and multiple smarthosts

2008-12-31 Thread Andrew Hodgson
Wietse Venema wrote:

Andrew Hodgson:

 I am trying to find the answer whether Postfix will support multiple
 smarthosts - i.e, sending to specific smarthosts, and if one fails, it
 will try to send to the next one in the list, or will just use any
 smart host in the list without issue?

relayhost = [one.example.com]
smtp_fallback_relay = [another.example.com]

Thanks for that.

Happy new year,
Andrew.



Re: Postfix and multiple smarthosts

2008-12-31 Thread Victor Duchovni
On Wed, Dec 31, 2008 at 05:38:33PM +, Andrew Hodgson wrote:

 I am trying to find the answer whether Postfix will support multiple
 smarthosts - i.e, sending to specific smarthosts, and if one fails, it
 will try to send to the next one in the list, or will just use any
 smart host in the list without issue?

Season to taste:

/etc/postfix/main.cf:
relayhost = example.com

/etc/named.conf:
options {
directory /var/named/data;
};
zone example.com in {
type master;
file example.com;
};

/var/named/data/example.com
$TTL 2D;

@ IN SOA a.ns.example.com hostmaster.example.com (
1   ; Serial
10800   ; Refresh after 3 hours
3600; Retry after 1 hour
604800  ; Expire after 1 week
3600 )  ; Minimum TTL of 1 hour
@ IN NS a.ns
@ IN NS b.ns
a.ns IN A 192.0.2.1
b.ns IN A 192.0.2.2

@ IN MX 0 a.mx
@ IN MX 1 b.mx
@ IN MX 2 c.mx

a.mx IN A 192.0.2.3
b.mx IN A 192.0.2.4
c.mx IN A 192.0.2.5

Non-local mail is sent to a.mx.example.com if that fails, it is sent
to b.mx.example.com and finally c.mx.example.com, or you can adjust
the MX preferences to be equal to get stastical load-balancing.

Alternatively, if all SMTP deliveries go to the smarthost, and you
don't want to or can't change DNS:

relayhost = [a.mx.example.com]
smtp_fallback_relay = [b.mx.example.com], [c.mx.example.com]

you can adjust the master.cf file to specify different SMTP fallback relay
lists for different (e.g. smtp unix vs. relay unix) SMTP transports.

-- 
Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
mailto:majord...@postfix.org?body=unsubscribe%20postfix-users

If my response solves your problem, the best way to thank me is to not
send an it worked, thanks follow-up. If you must respond, please put
It worked, thanks in the Subject so I can delete these quickly.


RE: Postfix and multiple smarthosts

2008-12-31 Thread Andrew Hodgson
Victor Duchovni wrote:

On Wed, Dec 31, 2008 at 05:38:33PM +, Andrew Hodgson wrote:

 I am trying to find the answer whether Postfix will support multiple
 smarthosts - i.e, sending to specific smarthosts, and if one fails, it
 will try to send to the next one in the list, or will just use any
 smart host in the list without issue?

[snip Bind config illustrating this can be done using DNS and MX records]

Non-local mail is sent to a.mx.example.com if that fails, it is sent
to b.mx.example.com and finally c.mx.example.com, or you can adjust
the MX preferences to be equal to get stastical load-balancing.

I did actually get this to work a couple of days ago, however in my case I 
manipulated DNS records on the content DNS server that resolv.conf was pointing 
at.  However, I want to try and do that with the Postfix conf if possible.

Alternatively, if all SMTP deliveries go to the smarthost, and you
don't want to or can't change DNS:

relayhost = [a.mx.example.com]
smtp_fallback_relay = [b.mx.example.com], [c.mx.example.com]

Ah, we can put two here can we?  Can you put two entries in the relayhost 
section also?  To make matters more complex, we actually have two Postfix 
servers at different sites with different Internet links at each site.  It 
would be nice to do the following:

Main site:
Smarthost to external servers (1 or 2 in any preference)
If unable to connect to either of these servers send the mail to the server at 
the second site (via private link)

Second site:
Same as above but probably no fallback smarthost as I don't want mail loops if 
both Internet connections are down or the two smart hosts go offline.

We are using these two servers as edge servers backing off to an Exchange 
server at the primary site.  We are not deploying Exchange edge servers due to 
the 64-bit requirement as currently we have several well specked machines which 
will run fine with Postfix et al, and I did the same type of thing a few years 
ago with another Unix MTA, but I am getting really used to Postfix config now, 
and want to keep it if possible.

Thanks.
Andrew.


Re: Postfix and multiple smarthosts

2008-12-31 Thread Victor Duchovni
On Wed, Dec 31, 2008 at 10:42:43PM +, Andrew Hodgson wrote:

 Ah, we can put two here can we?  Can you put two entries in the
 relayhost section also? 

Best to avoid reasoning by analogy when one can reason from facts.
The parameters are documented:

http://www.postfix.org/postconf.5.html#relayhost

The next-hop destination of non-local mail; overrides non-local
domains in recipient addresses. ...

http://www.postfix.org/postconf.5.html#smtp_fallback_relay

Optional list of relay hosts for SMTP destinations that can't
be found or that are unreachable. ...

The use of the singular in the first case and plural in the second is
reasonably clear.

-- 
Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
mailto:majord...@postfix.org?body=unsubscribe%20postfix-users

If my response solves your problem, the best way to thank me is to not
send an it worked, thanks follow-up. If you must respond, please put
It worked, thanks in the Subject so I can delete these quickly.