Secondary MX: Setup
Introduction
When there’s only one mail server handling emails for a domain, if it becomes unavailable, emails sent by third parties to the primary server will be stored in the spool (outgoing queue) of the remote server for a few days in the best case, or immediately returned with an error message (depending on the problem or the configuration of the remote server).
Since problems and unavailability are inherent in modern computing, it’s necessary to set up a system that can, at least in a degraded mode, transparently recover emails for the sender.
What does the Secondary MX do?
Its job isn’t very exciting (well, I think that’s the case for many web services)… It spends its time waiting for emails that arrive when the sending server couldn’t deliver to or contact the primary MX. When it receives them, it keeps them in its spool and tries at regular intervals to contact the primary server to transmit these emails.
Don’t forget to set up your mail server as an MX in DNS!
Configuration of Postfix
On the secondary MX
Main.cf
Edit the /etc/postfix/main.cf
file and adapt (use only one of these):
|
|
The form enclosed in [] eliminates DNS MX lookups.
By default, the SMTP client performs DNS queries even if you specify a relay machine. If your machine doesn’t have access to the DNS server, disable DNS lookups of the SMTP client as follows:
|
|
For smtpd_recipient_restrictions, check that you have these two lines:
|
|
Add this line to indicate the primary server:
|
|
SMTP Banner: If you’ve set one with the machine name first, don’t forget to change it to your secondary mx name:
|
|
Then insert this line to indicate the people to relay:
|
|
transport
Create a file /etc/postfix/transport
and insert this:
|
|
Example:
|
|
relay_recipients
And now create the relay_recipients file:
|
|
This must contain the names of the people to relay.
mailname
Edit the /etc/mailname
file and put your DNS:
|
|
Validation
Let’s validate everything now:
|
|
And we reload the Postfix configuration:
|
|
On the primary MX
Nothing to do :-)
Verifications
To see what we have in the spool:
|
|
If you’re in a hurry to retrieve your emails after bringing your primary server back up:
|
|
References
Last updated 23 May 2008, 07:43 CEST.