9 ms·
Exploring Self-Hosted Email Services
- johnklos 3y ago"Data at Rest matters." You bet it does. If you care about the security of your data, run your own server and use the VPS simply for its public IP. It's a good, lengthy article with lots of meat.
- 2Gkashmiri 3y agoagree for the most part but i dont like the execution. please use maininabox or something similar. it is also selfhosted and foss but you update it in one click and has 6 monthly 10 minutes updation. i have been using miab for over 3 years now. extremely satisfied with the result.
- XiS 3y agoLong time miab user here, recently switched to MailCow to make my host a run docker stack only (no more vms). Also, mail search on non email body finally is fast. Much love for MIAB still though. Self-Hosting email isn't that hard as it used to be (as long as you don't have to deliver to MS)
- NegativeK 3y agoThat "as long as" is doing a lot of work.
- 2Gkashmiri 3y agoplease explain
- em-bee 3y agobecause in the end most of the work you have with your selfhosted server is to figure out why MS (or, in my experience also google) rejects your mails and how you can fix it because you need to reach one person there. i gave up and started to use a secondary domain hosted with a paid email provider just so i can reach people that my selfhosted server can't reach. aside from that my selfhosted server is maintenance free.
- XiS 3y agoKinda true. In my experience only MS acts in strange ways. Had no issues with Google though. But if you don't want to struggle with delivery to MS, you can always give up and use a (paid) relay. Although this feels like losing tbh.
- Ayesh 3y agoGreat read. I miss these kinds of articles, compared to the "use this Docker image that has everything pre-configured" articles so common today. There's a much higher sense of achievement when putting things together with deliberate configuration and sorting out how to glue things together.
- TheNewsIsHere 3y agoSo many people are effectively cargo-culting software around at scale by just following along walkthroughs, examples, and tutorials. I’ve seen people who are moderately good developers panic when they have to troubleshoot while following a “golden path” playbook because they’ve seemingly lost the ability to troubleshoot. No one RTFM’s before doing stuff anymore. I have learned over the past many years that this has been key to my own journey and something others are willing to pay for.
- jeffbee 3y agoAt the beginning and at the end, the author mentions deliverability to major providers such as Google as the core outcome, but in between they don't substantively touch upon it. It seems unlikely that the goal was accomplished in a durable and intentional way.
- throw555chip 3y agoNear the end: "In order to deliver email to other mail providers without being marked as spam, I ideally needed to implement all three policy frameworks with the mail server." Then a few lines later: "Inbound and outbound message delivery was working."
- jeffbee 3y agoThose things are necessary but if that's the extent of their efforts then they are going to be sad.
- throw555chip 3y agoBeen doing it since 1999 and the things they mentioned are the main things to do, works great.
- rekabis 3y agoDeliverability is my only remaining issue, even after years being hosted on Vultr and doing “all the correct things” and staying off any and all blacklists. I frequently have eMails never reach their recipients because their providers just silently drop the incoming eMail. It doesn’t even show up in their junk folder.
- throw555chip 3y agoI've never used ansible but the article makes me want to consider trying it on my self hosted stuff. I wish I had that article years and years ago, the inclusion of how to configure virtual accounts for email is especially useful to anyone starting out.
- baz00 3y agoI used to run mail server for a large corporation in the late 90s. I always get really excited and nostalgic about running my own mail server when I see these articles. I have a spare domain I use for testing stuff on so occasionally I'll futz with postfix and dovecot for a bit etc and get something working on Vultr or some other cheap VPS. Then I'll spend an hour getting Thunderbird and K-9 working and I'll send and receive a few emails. Then I'll remember I just spent 6 hours of my Saturday fucking around with it and now have to live with it and maintain it. So I go crawling back to outlook.com like the pathetic corporate whore I am and go and do something less painful the day after. I'll just keep my private comms off email.
- chatmasta 3y agoI'd like to be a purist about email, but I just can't bring myself to care, because as long as my correspondent is a corporate whore, why shouldn't I be too? A copy of the email is going to end up on their servers anyway. In other words, I can only protect email from my provider as long as everyone else on the email protects it from theirs. And it only takes one gmail user on the thread to ruin it for everybody. If I'm corresponding with people who also care about this kind of thing, we aren't using email. If we absolutely have to, then we can encrypt it with PGP. My email use cases are: (1) b2b professional emails, which you expect to be retained for compliance, etc. and (2) transactional emails, which my provider unavoidably has access to and which I protect with strong passwords and 2FA. (That said, I would like to obscure the list of my internet accounts from google, so maybe one day I'll migrate my transactional emails somewhere else.)
- ishandotpage 3y agoThe corporates are pretty good at keeping self hosters emails out of their user's inboxes citing "Spam"
- radiowave 3y agoOne pragmatic solution to this is to use an email relay service to handle the outbound mail. Now, the hair-shirt self hoster's response to this idea might be, "But that means trusting a third party!" And indeed it does. But as the parent comment points out, in the vast general case we're committed to trusting whichever third parties our correspondent uses (or finding alternive means of communication.)
- hardwaresofton 3y agohttps://vadosware.io/post/its-never-been-easier-or-harder-to-self-host-email/ https://vadosware.io/post/its-never-been-easier-or-harder-to...
- muppetman 3y agoThis is exactly what I do. Debian + Postfix + rspamd. It basically runs itself, I login to the rspamd web gui every now and then and add a few hosts to the "trusted DMARC" whitelist so they get a better score through rspamd, but I don't really need to do that. I've been running it for ~5 years this way and it hardly ever lets a spam through (Very rarely the spams that are just images get through) and I've rejected 2 mails that I'm fairly sure were legit (just bulk marketing ones though) People always say "Use Mailcow!" and I say "But why?". Adding the additional complexity of docker with the random firewall rules it adds, individual containers that need to be fed and watered. It's a mailserver, all the processes are doing the same mail related function. Don't get me wrong, there's a very real place for Mailcow etc, but for a small end-user mailserver I think it adds overhead that makes running a mailserver more complex, not less. Anyway, great in depth article.
- rbut 3y agoI've done both vanilla postfix, dovecot, rspamd, etc and mailcow. For me the reason I use mailcow is it's a few commands and I have a fully functional mail, calendar, and contacts server with a web UI. It can then be updated with a single update.sh. Using mailcow I don't need to mess around with virtual domains, connecting it to mysql, DKIM, etc which is far more than a few commands. I also get a nice admin UI, web mail and CalDAV and CardDAV which you don't get with the above. Also I'd consider the separate containers a good thing so that if rspamd, or clamav, for example, has a CVE they can't pivot to other parts of your mailserver.
- muppetman 3y agoYou make a good point, especially around isolation. While I use docker and I know the basics of it, I'd hate to try and debug it if something went wrong (i.e. postfix container wouldn't start). For that reason I've stayed clear of using it for "critical" life things, like our email. For a number of years there my wife's business email I was also sending through my mailserver, so it needed to be super reliable. I'm not saying docker/mailcow isn't reliable, only that if it did break in funky ways, I don't have the knowledge domain to fix it. But I'm familiar with all the individual programs and running them on a "flat" linux system, so that's what I did. But yes, you certainly make some good points that are worth considering if someone else is reading these comments and thinking about doing it themselves!
- Uptrenda 3y agoI remember some articles on HN a while back about running your own email servers. I think they basically said that they would end up in spam for just about every contact. It seems like most people today use email that runs through Gmail. Who get to more or less decide how the worlds email should be processed. SMTP was meant to be an open protocol. It's really messed up what happened to it.
- kondro 3y agoIf you have DMARC and DKIM configured correctly, use a dedicated IP (so you can control its reputation) which you don't just start sending millions of emails from and have your SMTP server configured to communicate via TLS/SSL, you'll probably be fine -- assuming your IP hasn't been blacklisted in the past.
- anon291 3y agoI've never had any issues with deliverability. However, unlike most people, I purchase colocation space. This comes with more rights and better IPs than the cloud providers. It's also significantly cheaper when you factor in all costs.
- anon291 3y agoI have used simple-nixos-mailserver (not reviewed here) for three years now, for myself and several organizations. NO issues. The biggest issue with e-mail is (in my view at least) your IP reputation. In order to ameliorate this, I simply buy colocation space, which has higher quality IPs than AWS and cloud services. I've never had deliverability issues. Because it's nix, upgrades are atomic. Installation is dead simple. Also, the entire setup was like two minutes. I eventually added LDAP authentication and roundcube which took some work, but because it's nix, I did this development on a separate VM before I simply replaced my config on my main server (actually just copied the closures). Adding domains is simple: just modify the nix config file. As is adding new users. Very easy. Highly recommend to run all your critical infrastructure on Nix. Any mistakes are easy to fix... just go back to the old generation. I did consider solutions like mail-in-a-box but adding the complexity and statefulness of such a system just didn't seem worth it. Also, remote control panels scare me. My e-mail server is heavily SSH protected (Only my private key plus wireguard) and hardened against malicious IPs (fail2ban) among other things. Again, NixOS makes this easy. For storage, simple-nixos-mailserver keeps all data on a separate ZFS partition, which gets zfs 'send't to a remote backup (several).
- gerdesj 3y agoI run quite a lot of email services - self hosted. UK. It's not beyond the wit of man. I cannot believe that my IPs are blessed or whatever. My mail systems are behind "business" IPs but nothing more fancy. At work I have six WANs - a 1GBs-1 leased line, a 1Gbs-1 FTTP and four 80/20 FTTC. Our MXs are on two of the FTTC connections. We only have SPF set up, I toyed with DKIM and DMARC but disabled that and left as is. I run several "vanity" email domains and I never have problems with them. My own is an IP on the leased line, mentioned above. In the UK, it is possible to run an independent email system. I have been doing it for over two decades.
- dspillett 3y agoI run my own mail server in the UK on an FTTC line too, run off a more expensive ISP who take there network two seriously so I'm reasonably safe from being blacklisted due to other users on nearby ranges if I don't cock up myself (no significant issues in the last decade and a half). A friend who also has their domains going through my server did have Gmail give some recipients "are you sure this is the person you think you are taking to?" warnings a while back due to us but having DKIM setup for that domain, so I would say that is becoming necessary these days.
- dugite-code 3y ago> I cannot believe that my IPs are blessed or whatever. My mail systems are behind "business" IPs but nothing more fancy. The biggest issue is mail volume to establish reputation. You need a fairly high number of emails before Google or Microsoft's email Postmasters tooling even registers you exist. This leaves new servers stuck in a chicken and egg conundrum. You need to send X number of good emails before the emails are excepted, BUT you can't get emails through without having X number of good emails go through. Old servers like yourself have the advantage of already being "trusted" to an extent.
- cube00 3y agoIt doesn't change even over time, three years self hosting and I still can't get any of those tools to show anything beyond an error that there's no data available because my personal volume is so low.
- stevenjgarner 3y agoI have found this step-by-step tutorial for Postfix, Courier/POP & SASL with MySQL admin on Ubuntu LTS 22.04 (Jammy Jellyfish) most helpful [1] [1] https://www.postfix-tutorial.com/ https://www.postfix-tutorial.com/
- zx8080 3y agoCan it all work with ipv6 only?
- johnklos 3y agoIt can, but many email services won't work with IPv6-only email. It'd be a fun experiment, though. I don't think it'll work on your ZX80, though ;)
- Aachen 3y agoSpoiler: the "services" being "explored" are postfix + dovecot. Nothing against it, but that's not a plural comparison, that's one setup Fixed title: "Self-Hosted Email Setup Guide" To be fair, there's this bit (1935-ish words into the article) where there's some exploration going on > A number of free and open source MTAs are available for system operators including Postfix, Exim, QMail and OpenSMTPD. Each comes with their own limitations, quirks and security history. > I ended up selecting Postfix Too bad the exploration wasn't shared in this post: that's what I had clicked for
- Ayesh 3y agoI'll try to fill in. I'm very aware that I'm in a bubble with my peers, so these are certainly opinionated. I would pick Postfix because it's more maintained, and what most of my peers use it too. It's a PitA to configure, but there seems to be many resources online. Most of the configuration are quite common, so that one-time configuration is manageable. Exim is pretty robust too. I don't have a strong reason to not use it, except that I don't have many close peers who use it. Really nice configuration. If you have a multi-tenant setup, Exim would serve better. Qmail, despite being unmaintained, is praised for being quite secure. I suppose it's the low number of CVEs. There is also msmtp that provides sendmail compatibility, but uses an external smtp server (like AWS SES) to send the actual email. This is what I use when the server I'm sending from has low IP reputation but I don't want to change my app to use a REST API to send email.
- zilti 3y agoTry OpenSMTP. Ht is safe, and ridiculously easy to set up. I'll never go back.
- jjav 3y ago> I would pick Postfix because it's more maintained, and what most of my peers use it too. It's a PitA to configure sendmail would like a word... I find postfix is super easy and intuitive to configure. Still have nightmares of maintaining sendmail systems in the 90s. Exim seemed ok from the times I've used it but I use postfix now everywhere. Feels like it has the best combination of wide support and excellent documentation, good maintenance and being widely used.
- mattpallissard 3y agoI've ran MTAs and MDAs both personally and professionally at scale. I've hosted my own postfix and dovecot instances for about 13 years now for one reason, sieve. I cannot live without it. Honestly, the original setup of everything is a big lift if you've never done it but once you have ldap+krb5/PKI for auth{n,z}, DNS working properly, and a working POSIX setup (what used to be sysadmin 101) it basically runs itself in perpetuity. The underlying tech is old, feature-complete, and rock solid. Not to mention you're in full control of the entire stack. I honestly haven't had an issue after the first year and I use email HEAVILY. Though to be fair, I do have a bunch of ldap entries and routing rules in place so the power users can choose sieve+dovecot and all the plebs can use the Gmail webui.
- jmbwell 3y agoI went up this road. I ended up settling on Mailcow because it does all this same work and more, with pretty good integration and sensible choices, together with some valuable tools for things like migration and backup. If and when the Mailcow project goes away, it’s all still standard components, so moving to i.e. vanilla postfix and dovecot should be straightforward.
- MongoTheMad 3y agoThis is a good guide to set up an email server, yet it lacks describing PTR Records (aka reverse DNS) and that some cloud providers block outgoing email unless you ask support to turn it on.
- synlabs 3y agoOP here. This just made me facepalm. I set it up so early on in the project I forgot to mention it. Will update.
- asimpletune 3y agoThere’s also some upcoming stuff by stalwart labs that will probably be very good.
- INTPenis 3y agoWhy haven't we seen a Terraform setup of containerized email hosting on VPS yet? I feel like it would be really good because it could do the DNS setup with IaC, and therefore also support moving between providers if necessary. I know the risks of taking over someone's old IP to host email on of course, but with TF you could quickly re-deploy somewhere else until you find an IP that is good.
- drKarl 3y agoFor me it's not worth the effort to self-host, plus figuring out SPF, DKIM etc. Not being included in a blacklist because your server's IP address is on the range of a spammer... I use Mailfence for a couple of emails with my own domains, works well
- t312227 3y agoimho. (!) idk. what the fuzz is all about: yes, running a mail-server is a complex task - but nothing to write home about!! personally i prefer exim over postfix - because of its configuration: exim has a really flexible configuration-language which enabled me for example to operate qmail-ldap and exim-ldap from the same LDAP-tree - for migration purposes a few years ago -, using the qmail-ldap.schema vs postfix which insists heavily on the posix.schema ... additionally i prefer courier-imap over dovecot, for no apparent reason, just because i use it since ... ever. and i don't care about peoples performance who keep something like 10 k emails in their inbox/IMAP-folder ... yes, for this use-case dovecot is significantly faster / because of caching ;)) just my 0.02€ ps. i used qmail-ldap and qmail for over 20 years, and it was a really great piece of software - kudos to djb, but even brilliant code ages over the decades - for example, i didn't want to implement IPv6 support for outgoing mails myself / the available patch didn't cooperate well with the ldap-patch itself if i remember this correctly etc. pps. i would recommend: use an LDAP-directory for email ... openldap is an extremely lightweight and easy to operate piece of software. and its easy to replicate the db around - if you have multiple nodes in your mail-system - etc. ;)
- KronisLV 3y agoThis was a really nice and detailed writeup, what a wonderful read! For my own needs, I essentially let others do the heavy lifting and used docker-mailserver, which includes Postfix, Dovecot and some other software in an easy to deploy package: https://docker-mailserver.github.io/docker-mailserver/latest/introduction/ https://docker-mailserver.github.io/docker-mailserver/latest... Actually, that documentation of theirs is a nice read as well! I've been using this for a low volume of mails for a few years and haven't had much in the way of issues, deliverability, or otherwise. I even got lazy to the point of only configuring SPF, not DKIM or DMARC and have no problems there either (though that might change in the future). Throwing something like a Roundcube container into the mix when I need a web UI is exceedingly easy as well, as is setting up Apache (with mod_md), Nginx (with certbot) or Caddy as a reverse proxy.
- lbriner 3y agoI can totally understand the pain involved in setup. I have done the same with postfix+dovecot for our outgoing email servers and we now have 8 outgoing and 1 + 2 backups incoming allowing us to reboot for updates without losing too much capacity. I agree that the setup is a complete PITA but to be fair, postfix, at least, is very old and didn't have the benefit of what we've learned about best-practice configuration like having a single conf.d directory so things sit alongside each other nicely. The documentation is also very terse but Wietse did tell me that he's busy enough maintaining the software and porting all the docs is a mammoth task. I did do something myself converting the text files to markdown and using a SSG but there is too much stuff that I didn't understand well enough to re-word. There are also a tonne of compatability which has been added over the years which is no longer needed but still makes the docs feel a little overwhelming. My top-tip though, is to invest time in the Ansible setup script to avoid the scourge of following out-of-date blog posts line by line. We got to the point where we can provision a new server (manually) run the script and have everything setup ready to go, which is super helpful. The other important part is to monitor what is happening. Blacklisting can come upon you quickly and not always for an obvious reason but if you don't notice, it might be harder to resolve later and you might have lost a tonne of email. Instead, I semi-regularly spot an error in a log file and have to email someone or login to some ancient web page to request removal from a blocklist. We are generally always successful but it is also worrying that we have no direct control over it.
- iriomote 3y agoI have been enjoying using the ISPmail Guides from https://workaround.org/ https://workaround.org/ for years. They clearly state what and why you do it.
- TheWoodsy 3y agoI switched to mailcow recently to test, but I have fond memories of building it myself thanks to workaround.org He goes into great detail, and if anything edge-case arises, you can almost always find a comment relating to a fix before the main article gets updated.
- vsenko 3y agoDoes anybody run maddy (https://github.com/foxcpp/maddy https://github.com/foxcpp/maddy) in production or for personal matters?
- fx1994 3y agoI'm running small hosting service for me and my friends powered by ISPconfig (postfix/dovecot/rspamd) for more than 10 years, no issues at all and it's really easy to set it up these days. Just recently I installed new Debian 12 server, two-three hours work tops to setup 10 domains, mails, etc....