top | item 7117263

Ask HN: cheap ways to host your own email server?

53 points| _vya7 | 12 years ago

What are some relatively-cheap ways of hosting your own secure email server that's easy to bring back up in case of power outages or other common reasons for downtime?

This was initially inspired by and posted on the "Gmail is down" thread, but it got drowned out quickly by our collective lack of organization. (Why didn't we just start with a "me too" thread that people could respond to?)

52 comments

order
[+] treffer|12 years ago|reply
Buy a domain on a service that allows API-based DNS updates.

Put up a RPI at home. postfix + dovecot + roundcube should do the trick.

Add FW forwardings for 80/443/25 (or allow IPv6 to pass through)

Update DNS records every N minutes. (cron, nsupdate, dyndns clients, amazon command line tools....). You will need SPF/DKIM.

The RFC for SMTP says Mail Servers have to retry for 7 days before giving up on mail delivery. This should be plenty for your home server. There are also commercial Mail relay and backup MX services (sometimes even as a free offer for buying domains on website X).

You can backup the SD-Card whenever you want. Your Mail stays at locations you control.

I currently have a root server, but I'm heavily considering "in-housing" those services because of the NSA activities.

EDIT: it's 7 days PS: Some old firewalls block dynamic IPs for mail delivery. I'm not sure how common this is today, especially as SPAM and botnets have evolved a lot.

[+] eps|12 years ago|reply
Do NOT host at home.

For one, this violates every second provider's ToS, if not every single one.

For two, lots of providers block incoming SMTP connections on TCP/25. More importantly, they may start blocking it without notice and you'll have no clue that they did.

For three, you will most likely end up on a RBL (blacklist) in no time solely because you come from a "consumer" IP range.

I mean, hosting at home is technically simple, but in the end it created more problems that it solves. Get a hosted server and use it instead.

[+] FiloSottile|12 years ago|reply
> PS: Some old firewalls block dynamic IPs for mail delivery. I'm not sure how common this is today, especially as SPAM and botnets have evolved a lot.

The problem is not that firewalls block dynamic IPs, but that a lot of mail servers, to deal with spam servers, started accepting mail only from some trusted smarthosts.

So there might be some server that will reject your mails. (I don't honestly know how much SPF makes things better.)

However, your ISP SMTP server will accept mail from its IP range (as they know how to find you if you abuse the service) and will relay mail for you. So probably your best bet is setup outgoing mail to go through it (Internet site with Smarthost, or something like that).

Ah, and don't forget to setup your server for SSL!

[+] ubercore|12 years ago|reply
I think a lot of IP blocks show up in blacklists just by virtue of belonging to cable companies.
[+] jeremyw|12 years ago|reply
You might try Sovereign: https://github.com/al3x/sovereign

A large dollop of group experience wrapped up in Ansible recipes for your cheap VPS.

[+] FiloSottile|12 years ago|reply
Nice, but using a VPS kind of defeats most of the point of self-hosting.

There is still a third party that can give away your data, block your service and delete your emails pushing a virtual button.

[+] mjs|12 years ago|reply
For future reference (it's not ready yet):

https://www.mailpile.is/

(Features--privacy, encryption--are supposed to satisfy the most discerning HN reader.)

[+] jlgaddis|12 years ago|reply
Go to work for an ISP. My mail server doesn't cost me anything. =)

On a serious note, I've considered publishing the kickstart + deploy scripts I use for setting up mail servers. I'd have to do a bit of clean-up but I think it would be useful for a lot of people. I'll try to get to that in the very near future.

[+] ivansavz|12 years ago|reply
Yes plz do that when you have a chance. There are some good HOWTOs out there, but it is always good to see more examples.
[+] shiftpgdn|12 years ago|reply
I use a managed cPanel host and setup "catch-all" email addresses on my domains to forward to my gmail account. In the event of an outage or Google deciding to delete my gmail account I could change the forwarder or simply begin to use cPanel's built in mail clients. Having your email hosted at your own domain is one of the easiest things to do to gain control over something you normally let somebody else manage.

As to running your own email server? Don't bother. Unless you plan to stay on top of exploits, DKIM keys and SPF records you'll wind up with serious mail delivery problems.

[+] alextingle|12 years ago|reply
I've run my own mail server for many years, and delivery problems are very, very rare.

DKIM & SPF are marginally useful (at best) for ensuring delivery. You're much better off registering your server with http://www.dnswl.org/

[+] sp332|12 years ago|reply
DKIM and SPF are not that hard to set up. And it's a low enough barrier for entry considering that's all we have to stop spammers.

Edit: not sure about SenderID, to be honest.

[+] rosser|12 years ago|reply
When was the last time anyone had to patch their qmail instance? When was the last time qmail even needed to be patched?
[+] asdasf|12 years ago|reply
Where do people get these misguided notions about email? You don't need dkim or spf at all, few people check either, and they are just to prevent backscatter. Running your own mail server is trivially easy.
[+] bwood|12 years ago|reply
I found the guide "A Hacker's Replacement for Gmail" [1] extremely helpful in setting up my own email server. I run mine on a VPS which still makes me liable to 3rd party screw-ups or snooping, but it's a nice compromise between a massive service like Gmail and running a home server behind Dynamic DNS.

[1] http://dbpmail.net/essays/2013-06-29-hackers-replacement-for...

[+] alienfluid|12 years ago|reply
I wrote up a post [1] about running my own mail server a few months ago. I ran into issues with my emails being rejected by certain ISPs (AOL for instance) even though I (supposedly) had set up SPF and DKIM. Ended up moving to Outlook.com using my domain. Hope you have better luck!

[1] http://farhan.org/running-my-own-mail-server.html

[+] slashrsm|12 years ago|reply
What is the point of self-hosting if you send all your email through a 3rd party?
[+] ams6110|12 years ago|reply
Doubtful that anything you do yourself, especially "relatively-cheap" is going to have better uptime and less hassle than gmail (or other major provider), despite today's brief outage.
[+] JimmaDaRustla|12 years ago|reply
I would love to see some instructions to deploy something on a custom server or VPS.

I'm currently using NameCheap's e-mail service because setting up the software was too complicated.

[+] epaulson|12 years ago|reply
It would be great if there was some PaaS-type mail service provider. I'd like to get away from hosting it with a single VPS, and running multiple VPSes for redundancy seems frustratingly expensive for such low-intensity load like a personal email server.

Ideally, I'd sign up with one or two services and have each listed as an MX for my domain so there's always some service online to take the email. I can write my own app to hit both services and unify the two streams.

[+] stevekemp|12 years ago|reply
That sounds pretty cool actually. Assuming two servers had equal weight in MX records, such that mail had a 50/50 chance of going to either, you could unify it via fetchmail, or similar, if you polled both backends directly.

Usually it is a pain if you have mail going to more than one host - ie. no shared storage amongst all the hosts that receive mails, but if you were looking for redundancy and didn't mind the "manual fixup" this would be almost trivial to setup with 2+ VPS from different providers.

[+] squigs25|12 years ago|reply
Mailgun's api allows you to send and receive email using your own domain - I really like it, and it's free while your volumes are down.
[+] rubiquity|12 years ago|reply
It's a funny coincidence that this happened today as just yesterday I created a personal email for my custom domain with Zoho[0]. While not quite the same as having your own mail server it is nice to have at least one email not on Gmail.

0 - https://personal.zoho.com

[+] adders|12 years ago|reply
use Virtualmin (http://www.virtualmin.com/), it will configure postfix/smtp, dovecot/imap, dns & web hosting.

Its abit like cPanel & Plesk, but you don't need to use the control panel if you know what you are doing.

[+] lowglow|12 years ago|reply
Would anyone be interested if we did offer an alternative to Gmail? I've been noticing more and more of my friends wanting to move to something new, but not having better alternatives to move to.
[+] yownie|12 years ago|reply
My cheap solution a few years ago was:

1 year micro EC2 instance. This runs bind and dovecot/postfix. This could probably be done even cheaper with a home hosted RPI, but depends on your ISP's smtp relay rules.

free gTLD from dot.tk

done!

[+] walesmd|12 years ago|reply
My Synology NAS comes with a relatively easy to setup mail server. I wouldn't call it cheap, as a mail server alone; but all of the other functionality has made it well worth the price.
[+] stevenmays|12 years ago|reply
Just get a digital ocean VPS for 5 bucks and configure it.
[+] philosophus|12 years ago|reply
Yeah, that or you can get an EC2 micro instance free for a year on AWS.