I'm in the process of taking back control of my email hosting situation and I needed a backup mx infrastructure to handle receiving mails if my primary mail server (hosted at home) is unavailable for any reason. Ideally it should be as simple as possible to avoid any configuration mistakes that may cause you to lose mail, so I've selected OpenSMTPD for this purpose. It has a very clean syntax that makes this straightforward.
The configuration below requires minimal explanation. We're supporting TLS, accepting and relaying mails from the local OS, and relaying mails for all domains in the domains
text file. Additionally we will hold mails for up to 30 days (default is 4 days) before bouncing in case of a rather serious unexpected disaster with my internet or mail server infrastructure.
The helo
and hostname
settings are simply because the hostname of the server differs from the hostname I use for this service.
queue compression
queue ttl 30d
pki mx2.feld.me cert "/path/to/cert/mx2.feld.me.pem"
pki mx2.feld.me key "/path/to/cert/mx2.feld.me.pem.key"
table aliases file:/etc/mail/aliases
table domains file:/usr/local/etc/mail/domains
listen on 0.0.0.0 tls pki mx2.feld.me hostname mx2.feld.me
action "local" maildir alias <aliases>
action "relay" relay helo "mx2.feld.me" tls
action "backupmx" relay backup helo "mx2.feld.me" tls
match for local action "local"
match from local for any action "relay"
match from any for domain <domains> action "backupmx"
Simple, clean. Just works.