A secondary MX (mxbackupd)
A secondary MX takes mail for your domains while the mail server cannot: during an upgrade, a network fault or a longer outage, senders' servers deliver to it instead of retrying elsewhere or giving up. mxbackupd is one, built to run on other hardware.
What it does
- Accepts only real addresses. It accepts mail only for the domains the mail server hosts and the addresses there that take mail (mailboxes and their aliases, mailing lists, rooms and equipment, with any
+tag), and SRS bounce addresses on those domains. Anything else is refused at once, so it never collects mail for addresses that do not exist (backscatter). It pulls this list from the mail server every minute and keeps it on disk: when the mail server is down, it goes on accepting from the last list. - Keeps mail on disk in its own queue until the mail server takes it.
- Hands mail over every 30 seconds, through the mail server's relay API. The mail server runs every check as if the message had come to it directly from the original client (its address and HELO name): SPF, DKIM, DMARC, ARC, domain blocks, spam filtering, Sieve filters, mailing lists and vacation replies. Greylisting is skipped, as the secondary already took the message.
- Bounces what the mail server refuses for good (a mailbox suspended meanwhile, say) and what it could not hand over within the hold time (five days unless set). The bounce goes to the sender through the mail server's outbound queue, from
MAILER-DAEMONat the mail server.
Setting it up
- On the mail server, make a relay token (32 random characters or more) and set its SHA-256 in
CORPSUITE_RELAY_TOKEN_SHA256. The token is for the secondary only, apart from the platform's service token. Build
mxbackupd(make mxbackupd) and run it on the other machine with:Variable Meaning MXBACKUP_HOSTNAMEIts host name, such as mx2.example.com(required)MXBACKUP_PRIMARY_URLThe mail server, https://mail.example.com(required)MXBACKUP_RELAY_TOKENThe relay token (required) MXBACKUP_SMTP_ADDRWhere to listen ( :25)MXBACKUP_DIRIts queue and recipient list ( /var/lib/mxbackupd)MXBACKUP_MAX_MESSAGE_BYTESThe largest message (50 MiB) MXBACKUP_HOLDHow long mail waits before it is bounced ( 120h)MXBACKUP_TLS_CERT,MXBACKUP_TLS_KEYA certificate for STARTTLS (optional) - Publish it as a lower-priority MX for each domain, after the mail server:
example.com. MX 20 mx2.example.com.(the mail server beingMX 10). Add its address to your SPF record only if it also sends (it does not: bounces go out through the mail server).
mxbackupd version prints its version. Its log names each list refresh that failed and each hand-over that did not go through; the queue is the *.json and *.eml files in its directory.