Fault-Tolerant E-Mail on the Cheap

Ever wanted to run your own e-mail server for family or friends, or even a small business, and didn’t want to use a commercial service, but didn’t want to face a single point of failure in what is, after all, the internet’s killer app?

Well, it’s kind of inelegant, but here’s how you can create an e-mail system that’s robust, scales well, has (very!) high availability, and provides redundant storage… all on the (very) cheap.

What you need:

1. A domain name, with redundant DNS service, and the ability to edit your zone information.
2. Hosting on two (or more…) servers. They can be your own servers or virtual severs, somebody else’s servers, shared hosting from two different companies… whatever.
3. Familiarity with the way e-mail and DNS works.
4. Patience.

Here’s what you do. The instructions are for one e-mail address and two servers, you’d just repeat as necessary for additional ones.

Give each server a name – a subdomain under your domain. For our purposes, we’re going to call them “east.example.com” and “west.example.com”. Point these as A records to the appropriate IP address. (These will be used as MX records, so don’t use PTR records.)

On each server, setup mailboxes for something other than what you’d like your actual e-mail address to be – like, say, “reallybob@example.com” with identical passwords.

On each server, setup an your preferred e-mail address at that server’s subdomain – i.e. if you’d like to use “bob@example.com”, here you setup “bob@east.example.com” or “bob@west.example.com” – as an alias that forwards to “reallybob@example.com”.

On each server, setup your “real” e-mail address (let’s say “bob@example.com”) you want to receive e-mail at, as an alias that forwards to both “reallybob@example.com” and “bob@theotherserver.example.com”.

Set your MX records for “example.com” to be both east.example.com and west.example.com with idential priority.

Set your MX records for “west.example.com” and “east.example.com” to point to themselves, i.e. mail for west goes to west, mail for east goes to east.

Set a subdomain like “mail.example.com” to point to both IP addresses, for east and west servers.

Set your mail client to connect to “mail.example.com”, while authenticating as “reallybob@example.com”. Make sure your mail is set to send as from bob@example.com.

That’s it.

What happens is that when someone sends you an e-mail to bob@example.com, it’s randomly delivered – assuming both servers are up – to either east.example.com or west.example.com, where it’s delivered into the local copy of reallybob@example.com’s inbox, and forwarded to bob@theotherserver.example.com, where it gets shunted into the reallybob inbox there, without forwarding on anywhere in an endless loop, which would be bad.

Within a couple of seconds, your mail is stored on both servers – essentially real-time backups.

Even if one server is offline, mail to your domain is delivered as normal, with no interruptions.

Pretty slick, no?

There is a downside – as your connection ping-pongs back and forth between servers, messages in your inbox may appear to undelete themselves, or revert to being unread. It’s not ideal, I admit – but the idea here is to be robust and reliable, not user-friendly. This is one of those things you only do because you’re a nerd, probably. It does work, though – and if you’re a cheapskate who’s addicted to e-mail, knowing that your e-mail is powered by a kludged-together network of six servers in four countries on two continents has got to be pretty heady stuff. 🙂

Published in: Geekiness, General | on April 4th, 2011| Comments Off on Fault-Tolerant E-Mail on the Cheap

Both comments and pings are currently closed.

Comments are closed.