17
votes
Self hosting email at home?
I recently set up kubernetes to run on an old laptop. The goal was two-fold, 1 learn kubernetes and 2 setup an instance of nextcloud. I've managed to set everything up with cert renewals for my domain and enabled dyndns in case my provider changes my ip. All well and good and quite nice learning experience! Now I would like to also start running my own email server and have some questions. Is ther any that have a helm chart that is easy to setup in kubernetes? Since I am running this from home I imagine I'm more likely to be classified as a spammer. What can I do to minimize the likelihood of that? I read somewhere about reverse DNS, but not entirely sure if it is possible to do given I am running it all at home via a regular ISP.
If you are going to host your own e-mail you should make sure to look into SPF, DMARC, DKIM, and setting up reverse DNS. These things should help prevent you from being classified as spam. I don't know anything about kubernetes, though, so I can't say anything about that.
I run my own mail server on a NixOS machine using Simple NixOS Mailserver - they have a tutorial that goes over steps you can take so as to not be classified as spam.
Excellent I'll dive into the tutorial and see what is applicable in my case!
I'll give the standard warning you'll see in response to a lot of people who want to self host email: I've been told it's very difficult, time consuming, and fraught with errors, especially in regards to spam / spam filters. If you're looking for a reliable mail solution, you should not be self hosting your own email.
That being said, for learning purposes it's an excellent exercise.
If you're looking to "own" your own email, I recommend going with a free provider of an email service. For instance, I use Zoho - they allow me to bring my own domain, and allow you to configure SPF / DMARC however you please using DNS. It's set it and forget it, I haven't had to do any admin work on it since I've set it up.
Side note - does anyone know of alternative free BYOD(omain) email providers other than Zoho? I'm pretty happy with them, but just curious.
I see this advice all the time and don’t understand it at all - I have been hosting my own mail server on a VPS for a while now and have not had any sort of issue with spam filters or configuration. I will say that I’m cheating a bit since NixOS makes configuration easy, but I don’t think it’s anything that would be difficult to do on a more traditional system. In fact, I had a harder time setting up a matrix server. On top of that, SMTP is supposed to be a decentralized protocol - it makes sense to host your own if that’s feasible to do properly.
It's very doable to host your own e-mail, but in fairness it's a lot more complicated than even the average technical person might assume at first glance. I assume most people come into it thinking "I just run a daemon on my server, and maybe it talks to a database", but the setup is usually more complicated.
E-mail is not just one protocol, and you generally have to run multiple services that all connect to each other in different ways to get SMTP / IMAP / POP / DKIM / spam filtering all working in harmony. You might have postfix for SMTP, dovecot for IMAP / POP, another service like dkimproxy for DKIM, another service for spam assassin, and you might even have something like clamav for virus scanning. On top of that you'll need to set up a database for many of these services to connect to. That's 6 different things that need to be configured to talk to each other nicely, and on top of that you'll also have to set up appropriate DNS records for SPF / DKIM / DMARC. All of these things can go wrong, and if you don't really know what you're doing it can be hard to debug which piece of what is broken! Especially when sometimes it's just that some other mail server decides to bin your messages, and you have no idea if that's even happening.
So, it's not impossible to set up your own e-mail... In some sense it's not even that hard... But I think people often end up biting off more than they can chew with it, and it's particularly dangerous if they're trying to use it for anything mission critical. The time investment to understand all of these components and how they interact is generally not worth it for people, and I think the warnings about setting up your own mail server as a result are totally justified. Can still totally be worth doing if you're interested in it, but generally the benefits for people are quite small when e-mail services are so cheap.
In contrast, I would have thought that setting up an XMPP server for instant messaging would be more complicated, but it's pretty much a breeze to set up something like prosody because it more or less just has one moving part.
That's pretty much exactly how it went for me, though I had the luxury of being a student with entirely too much free time, to figure stuff out.
The initial setup is not all that complicated, actually, as the Arch Wiki tells you pretty much exactly what to do ( for those interested: https://wiki.archlinux.org/index.php/Virtual_user_mail_system ).
The difficult bit was in figuring out afterwards what I actually did, and whether what I did conformed to what I wanted to do.
There are indeed a lot of moving parts, but after about a week of tinkering with it basically around the clock, back in 2015, I think, and some maintenance every now and again (and recently adding DMARC), it's been amazing.
To be fair, I'm a nerd that likes that sort of thing, so YMMV.
zoho only provides free mail with a web interface (a couple of years ago the free tier was more generous), they charge for IMAP etc. - I've been with zoho for 3-4 years now, it's about 14$ per year for the most basic plan with IMAP, custom domain, DKIM, SPF and I really like it.
I've read gold things about Migadu, but haven't person ally tried it.
https://drewdevault.com/2020/06/19/Mail-service-provider-recommendations.html
I'm surprised you're going with Kubernetes especially if you want to learn. Is there a reason?
If you really want to self-host email (I recommend against doing it as anything more than a learning experiment; aka "don't do it in production"), I heard a lot of good about Mail-in-a-Box.
I wanted to learn kubernetes so setting that up to run my nextcloud server felt like a good candidate for learning. There are a few moving parts that was good to get familiar with this way, ingress, cert-manager, helm etc. Is there a reason not to use it other than it being a bit too complex for my needs (if I am being honest)?
Got it in one, it's far too complex for what you need. Learning Kubernetes is super useful so don't let me stop you but it might impede in learning the other self hosting stuff you were looking for.
Yeah, definitely agree it is overkill to setup kubernetes at home, but I think that's part of the charm too :) Just need to find a few extra old computers I can set up as additional nodes. Then to figure out an overkill backup solution... probably need to involve a couple of friends at least on in New Zealand and another in the states. A three way redundancy should be enough for guarding against most disasters. Even with a sizeable meteor impact one of the sites should be ok. What more can one whish for in a post-apocalyptic world ravaged by the aftermath of an impact - the sun completely blocked out by the dust cloud? At least I will die knowing my backups should still be ok...
I use opensmtpd and it's a breeze. No problems with spam, dropped emails etc. Really easy to configure and maintain. I can post details later when I get home if anyone's interested.
OpenSMTPD is the real answer :).
You might be interested in https://www.onmail.com