It is now quite a few years since I started running a mail server. Why did I bother? Well two quite different reasons persuaded me.
First there was the obvious issue that I wanted to have more control over where my emails were being stored. Running your own mail server certainly doesn’t make them totally secure, but it does seem a step in the right direction. I was also dubious about people offering me free email services. They may sound like a bargain, but it is always worth considering the adage that with free services you are the product and not the customer. Do you want your email traffic analysed for someone else’s benefit?
The much more practical consideration was that I was running a number of domains, and wanted an email address on each of them. Most of them would have very little traffic, but it is unprofessional not to use email addresses associated with your domains. Having decided against too much reliance on free services, the problem is then that paid for email services normally charge per mailbox. Even if there is very little mail to handle. That means that having a number of lightly used mail boxes becomes quite costly.
Oh, and apart from the sensible reasons, there is the fun of setting up your own mail server, and overcoming the challenges. It’s a quite technical area and it is easy to make mistakes that completely break the server. But I did get one going, and have continued ever since. I always use my preferred server operating system, Debian Linux. And the standard choices for a web server of Postfix and Dovecot.
Setbacks for running a mail server
The first point at which I backed off a bit was over mail sending. It wasn’t too difficult to make it work, even when you throw in the added complexities of DKIM and DMARC. The killer, though, was the policies of the big mail handlers such as Microsoft and Google, and if you are in the UK like me, British Telecom. They think nothing of blocking the mail from a personal mail server, and it is a waste of time and effort attempting to complain.
Having your mail blocked might not seem so unreasonable if you had done something to deserve it, like sending mountains of spam. But I was very well behaved, and still got blocked. At the time, I was renting VPSs from Digital Ocean. It turned out that the big email handlers were quite prepared to block the entire set of IP addresses used by Digital Ocean. Maybe some customers were misbehaving, but blocking everything is a bit extreme. But as I said, as an individual you are wasting your time attempting to fight the big boys.
So from there on, I subscribed to mail relay services. Although they are designed primarily for people running mail shots, they do make a big effort to keep their mail servers off the blacklists. And when they get blacklisted, they quickly work to resolve the problem. They have much more clout than me (I really couldn’t have less). There is no reason not to use a mail relay service for all mail sending, especially if you do run occasional mail shots. You get a lot of nice features for monitoring what is happening to your sent mail, rather than just dispatching it into the ether and hoping for the best.
Going for a bargain mail server
That all worked well for quite a while. But the cost of the mail server was niggling, even though it was a good deal less than commercial services would charge for the same number of mail boxes. The problem was that a fairly powerful server is needed. You need a good deal of disk storage, assuming that you let mail accumulate as I do. You also need a good deal of memory, because the inevitable anti-spam and anti-virus software are memory hungry. Processor power isn’t an issue — it take a lot of mail to put any serious demands on the processor. Bandwidth is not likely to be an issue either unless you are handling a quite exceptional volume of mail.
Then browsing around, I started to review cloud services for anti-spam and anti-virus. Many of them are designed for corporates and have big price tags way beyond anything I could justify. But I found that MX Guard Dog was offering a spam and virus filtering service for just 25 cents per email address per month. Better still, if you have a popular web site and are willing to post a link to MX Guard Dog, you receive credits that may well cover all your costs. It is not the fanciest service and some of the interfaces look dated, but it works, which is the main consideration.
How did it work out?
Without the issue of spam and virus filtering, I could run on a server with much less memory. I decided to see how far I could push it and rented a storage VPS with 512MB of memory and 128GB of disk. It was provided by Alpha VPS for the impressively reasonable price of just 15 euros per year. The disk space was more than adequate — currently all of my email accounts have run up to 19GB. CPU is not an issue — it is idle for 94% of the time.
Memory is quite stressed. Careful configuration of Postfix and Dovecot have kept demands fairly low, though. That still leaves room for a fair amount of cache and a bit of free memory. There is swapping, but it averages less than 1 page per second, which is pretty good. A terminal session tends to be sluggish, but that doesn’t really matter, and mail doesn’t need very high speed operation. There is no sign that the server isn’t coping with the really quite modest mail load. All in all, the server is functioning well. And it is only costing me 15 euros per year.
There is a security bonus. The server is configured with nftables firewall. Since all the incoming mail comes from MX Guard Dog, port 25 can be restricted. A hostname allows a lookup of all the IP addresses that might send mail to my server, so any changes are automatically handled. None of the other ports are open to the world, so I now have a mail server that has no generally available ports. Any hacker scanning for open ports will not find anything at all. How does that work with mail clients accessing mail from the server? Well, that is a question for another day!