No, that’s it. I am f#*&@-ing done. I went from gmail to tuta to proton. Now I hear something like FastMail. Some say privacy, some say security, but what they never say is corpos gonna corpo.
No, I am done using third party services. This may be a Sisyphus task, but I want to self host a mail server even if 60% of it goes to another person’s spam.
I’ve heard about Dovecot and some other services. While searching YouTube, I came across a defunct channel that still has this old video that gives instructions to selfhost email: https://www.youtube.com/watch?v=9zP7qooM4pY
Cherry on top would be to have as many parts with the GPLv3 license as possible.
Any guidance or instructions would be greatly appreciated. I have a domain name and I am currently hosting a small webpage for fun. Nothing serious.
I’ve been running my own email server since around 1996. I go old school with sendmail and dovecot on linux, but sendmail isn’t for beginners…postfix or exim are easier to configure with lots of add-ons available, and others have suggested several other MTAs that are probably just as good. Nowadays its more work to get started with sending emails (w/o getting rejected immediately as spam) since you’ll need to configure DMARC, DKIM, and SPF along with reverse DNS, but not that hard if you’re somewhat technical and willing to learn. The big providers get to set the rules here, and they’re incentivized to make it hard for a self-hoster, because that also makes it harder for spammers. The first few weeks your emails will get directed to spam folders until the providers learn your domain and associated IP address aren’t from a brand new fly-by-night spammer but it’ll taper off, you just gotta keep at it.
The biggest annoyance and work honestly is on the receiving side, with all the spam filtering work you’ll need to do once your email gets onto the spam lists. The big email providers have entire teams set up for this. You’ll also need to set up your own DNS resolver to use spamhaus and spamcop blacklists (which is what everyone uses because they’re so good), because all the public resolvers (and the shared resolvers at your VPS or cloud provider too) are already hitting them so much they get rate limited. Good news is once you get those blacklists configured correctly that’ll take care of probably 80% of the spam, then a standard open source package like spamassassin or spamprobe normallys gets most of the rest.
Another reality is that your home residential connection won’t let you send email from their network; this really reduced spam as people’s compromised machines can’t be used to send spam anymore. However, there are providers out there intended for home self-hosters that will route you a static IP that you can configure reverse DNS on and enable outbound port 25 connections. https://getrealip.net/ is one of them, see their guide for self-hosting email here: https://getrealip.net/guides/self-host-email-server/
good luck.
i tried that many years ago and it is lot of work and it sucks. your important emails will get blocked on recipient servers for all kinds of reasons and their emails will end up in your spam folders… and that was before the gmail, outlook and yahoo (that host most of the addresses with which you might want to interact) went full mafia and started inventing all kinds of non-stamdard rules to block smaller providers out and changing them at random.
i admire your intention and optimism but hosting is hard.
I run my own email server. Of all the services, email is the most complicated and weird and fucked up. It’s hardcore doing it yourself. I’m glad I do, but make sure you have the time and energy to get it all going.
Do serious research first. Make sure you have time. Make sure you have a good VPS or commercial ISP. Don’t be half assed or it will fail.
I was looking at Tuta, what are the negatives?
Besides being bound to their web interface or client apps (no thunderbird) I haven’t found any.
Some folks have complained about service outages or account locks, which is something I haven’t seen in my year and a half using the company, but nearly universally they are revealed to be free users and not subscribed to any tiers of service.
My one and only complaint about my experience inside of using Tuta is a fairly restrictive rules system, after growing up with robust platforms like Ms Outlook. But it’s worth a few Euros a month for me to not use Google and to have excellent calendaring that functions on par with Gcal for me.
Thanks
So what I did has worked great.
Life is way easier if you are running something like opnsense as your firewall. Then you have really good spam filtering available at the firewall through e.g. pfblocker.
I learned Exim. It’s super configurable and stable. I got a VPS and put another instance of pfsense on it with wireguard tunneling back home to my dynamic IP (which pfsense handles via dyndns). The static IP and VPS costs about $5 a month. Exim lives on the home machine and haproxy on the remote VPS handles email receipt and forwarding.
Only a few problems with the IP when new getting blocked by Google. I had my SPF/DKIM/Dmarc set up and requested unblocking and they did it in several days, and that was all.
The advantages here are that you can easily update without changing configs, the wg tunnel is stable, and your host remains on your own server, and pfsesne along with spamassassin and the native routing and session tools in Exim kill most spam.
Some investment up front can really pay off. Oh also you can use ACME on the pfsense instance to handle all your certificates through let’sencrypt automatically.
Here is the issue with self hosting email. Residential ip’s are pretty much verboten from being able to receive email by the big companies. That means everything you send it will be automatically deleted. That’s if you can even set it up to work as most ISP’s block the needed ports. No a VPN won’t fix this or solve the problem. You can receive with no problem but to send you will need to use something like SMTP2go or if your ISP is capable (and willing) they can send.
If you want someone to blame look to the Spammers and Hackers of the world.
I’m in the process of moving everything I do to self hosted as much as possible. Email is a bigger nightmare than web hosting at home. The only other option I can find (for self hosting) is collocation of your server in a data center.
Surely you get set up everything you need on a VPS though, right? You can even rent a Raspberry Pi in a rack in the UK if you want and that’d work for email, right?
Correct, a VPS or a Raspberry pi in a data center can be used. You would still need to install the software and configure it.
Actually you can just rent a small vps with a provider that allow outgoing port 25 and reverse DNS just to send email. The receive part can be configured in your home server. That’s what I’m trying to do, but I’ve only configured the sending server.
I have both, a VPS with wireguard to bridge it into my network as exit point, and a dedicated bridge from an IPv4 provider.
The latter costs a few bucks and gave me a very reputable IP with rDNS etc.
The former also supports rDNS, but the IPv4 I got was flagged by multiple spam blockers and needed some work to unblock with all those blocklists.
Postfix + dovecot are on my main server behind a residential IP, where I can without problems communicate with clients (IMAP/POP + SMTP) and receive mail (set the IP as MX with lower prio number to force it as first choice for remotes to connect to SMTP with), but not outgoing SMTP (called ‘smtp’ (mail sending/forwarding) in contrast to ‘smtpd’ (mail receiving) in postfix). That’s specifically routed through the IPv4 provider and then the VPS (IPv4), or directly through the VPS (IPv6).What is the ipv4 bridge provider you use?
I paying a 2USD VPS in IONOS with posfix as SMTP server.
Wait, I know colocation in datacentres is a thing but can you actually collocate raspberry pi?
You can put whatever you want in your rack allocation. You could put a Sega Dreamcast if you wanted.
Seconded. I used to selfhost email, and it’s a pita. Doable, sure, but in my case I concluded that it just wasn’t worth it.
If you want someone to blame look to the Spammers and Hackers of the world.
But don’t forget the reason why all of this is necessary: email was created by hippies, and therefor any kind of security was really not on their minds when they built this stuff ;-)
Ah yes, the hippies at ARPANET
That was the network, but email itself is a very hippie thing.
https://en.wikipedia.org/wiki/Jon_Postel
I cite this article regarding his death: https://circleid.com/posts/in_memory_of_jon_postel
Jon loved the outdoors. I know he used to enjoy backpacking in the high Sierras around Yosemite. Bearded and sandaled, Jon was our resident hippie-patriarch at UCLA. He was a private person but fully capable of engaging photon torpedoes and going to battle stations in a good engineering argument. And he could be stubborn beyond all expectation. He could have outwaited the Sphinx in a staring contest, I think.
Edit: Here’s a picture of email’s hippie-in-chief:

Seems like he was a great guy, but security was not on his mind back then.
A bro named “Postel” helped develop Email standards. What a trip. :-D
Bro wrote like half the Internet rules
Very cool!
Security isn’t the issue. The problem is inherent to any system that lets someone communicate with you without your prior approval.
If physical mail cost nothing to deliver, junk mail would be a gigantic problem instead of a nuisance.
I am honestly very thankful I am in Canada, with a good ISP. My (non-static) IP hasn’t changed in 3 years, and there are no non-piracy restrictions on it at all. Self hosting email was as easy as following Maddy’s setup instructions in a lxc, and pointing Caddy at it. I did set up smtp2go for outgoing mail, just to reduce the chance of it hitting spam on the rare occasion I need to send a personal email, but have had 0 issues receiving.
If you want someone to blame look to the Spammers and Hackers of the world.
Side note, blame the people buying what the spammers are selling. Nobody would spam if it wasn’t profitable.
For $3 a month, forwardemail will forward both inbound and outbound email for you. You’ll still have a lot of work setting up DNS entries and spam filtering, though.
I’ve self-hosted email for over 25 years. Much has changed, but the basics are still the same - and it’s not difficult.
The first thing I would ask though is what are you looking to spend, before any required hardware? Meaning just the reoccurring provider fees, whether that’s your broadband ISP provider with static IP service added on (this almost always requires a business account, also very easy to do), or a cloud VPS provider (probably cheaper)?
Thank you! I don’t get why these threads are always so full of FUD.
Once I setup email it’s been little to no maintenance. Very “set it and forget it”. I check my logs after I see the software updated by my package manager to catch breaking changes. Which are super rare. I’ve had to increment a version number in a config a time or two.
There’s no FUD, just D.
Hundreds of us here on Lemmy have hosted our own email before, some (like me) for over a decade. We share our opinion that it’s on balance not worth it as (from experience) it’s a massive pain in the arse to keep yourself off blacklists. You do you though.
I had to do a thing with Google one time to validate my IP so that Gmail didn’t mark mail from my server as spam. I’ve never had to do any sort of blacklist removal process. I’ve been hosting email for my own domains since 2006.
What gets y’all on blacklists?
My VPS’ SMTP config used to work and now doesn’t sure to spam prevention shit
Seriously do you not get blocked at all? You never fail to get email you expected? How much of your time is spent petitioning off of blacklists?
I very rarely have to deal with blacklists for my email servers. But that’s when using a paid-for static IP address. Which is why I asked about budget. When you implement a proper DMARC framework with both DKIM and SPF you’ll have no problems with your emails reaching your recipients’ inboxes. Now, if you let other users send mail from your server you have to make sure they enforce good login security. That’s where you can get yourself on a blacklist.
Running an email server with a residential broadband service makes things more complicated and requires more frequent intervention.
For my IoT email servers, I have to attend to those a bit more with the black lists because even if you purchase static IP assignment with your commercial wireless service, those IP blocks are submitted by the carriers (Verizon, T-Mobile, etc.) to databases like Spamhaus to deliberately flag them as wireless static. With Verizon’s blocks, you have to remove yourself from the soft black list once a year. T-Mobile submits their IP blocks with an additional flag that prevents you from removing your IP from Spamhaus at all, so T-Mobile static IPs are not good if you need to direct send without user authentication.
I’m also selfhosting mail and I had to do some initial work to remove the server’s IP from blocklists. That was pretty much it.
Receiving email isn’t an issue. Other servers will just send them, I think they only check the blocklists if it’s the other way 'round. Gmail is a bit nasty, they’ll occasionally do weird things if I send out newsletters and mailing lists. But with all the other providers it’s mostly just fine. Issues arise once I (inadvertently) forward spam. That leads to some extra work.
I do have to tune my own spamfilter regularly. So there’s some effort I put in.
Email self-hosting doesn’t have to be difficult. Ignore the detractors here.
I want to throw another option into the mix: nixos-mailserver. It sets up and manages a classic stack of email services. Through the magic of nix, you get a VERY reliable setup, and all the difficult parts (and those you don’t care about) are abstracted away in a really nice manner.
If you either already know nix, or are OK with investing a bit of time into learning the ecosystem, I urge you to go this route.
I’m running it on a Hetzner server. Had to ask them to open port 25, which was no issue. Set the DNS records as in the linked docs, and immediately had a 10/10 on mail-tester.com and no issues found on mxtoolbox.com
It’s also super easy to add additional domains. I’m hosting for multiple people now. Literally zero issues.
Again, don’t listen to the fearmongers. You got this.
It’s not the software that’s the issue. The issue is other sites not recognizing your server as legitimate, or your server being hacked and used to spam and putting you on a spam blacklist.
I had to give up independent hosting because of that.
Again, all records are correct and I have a perfect score on spam benchmarks. That’s at least partly a result of the configuration.
Getting hacked is a risk, sure, but with a common sense approach you can mitigate the risk pretty well. It’s also not unique to email hosting.
Sorry to hear you had a bad experience with it though.
The problem is that google treat all small domains as spam.
I land in inboxes on google accounts without issue.
t-online was a problem initially, because they refuse mail from unknown domains, but it only took an email to get whitelisted. Apart from that, zero issues.
I did the exact same setup you described, hetzner, nixos mailer, all the dns setup was perfect, ipv4 and 6, perfect scores. Every single message landed in spam. I followed all google and Microsoft guidance and submitted to their whitelist forms, made no difference. I can only think i got a recycled ip that was blacklisted already. I use mailbox.org now
Dang. Yeah, recycled IP with a bad rep is unfortunately a real risk :/ Had you tried requesting a different one to see if it made a difference?
deleted by creator
deleted by creator
People say this but I haven’t found it to be true at all. Are you just repeating the folklore of the self hosting community or are you speaking from experience?
Wait until the major providers randomly black list you for no apparent reason
How many years should I wait for that?
Well, kind of true. Email servers depend on the actual server you use, how it is configured, the DNS records and the routing. Those are the main 4 components that can make or break self-hosting email.
I self-host absolutely everything, and email was the last frontier for me, and it scared the shit out of me in ways you probably can’t imagine.
I’m not a developer, certainly not particularly smart, and make so many fucking mistakes on a daily basis that half of them is already too much.
So I decided to study the evolution of email all the way to today, what each part does, how much control I would actually have over each part if they break, and got to work. This is what landed me on deploying stalwart in a cheap VPS, but even though my VPS allows port 25, precisely because that is the part I have no control over, all SMTP is routed over SMTP2Go.
Do I already understand every single gear involved in detail? No. Am I prepared enough to tackle something that can go wrong? Absolutely, and I’m still learning.
It so happens that my fear came from reading all the horror stories from the people that tried, failed and gave up. Turns out that, while it is the single most involved service I have deployed in my self-hosting track, its absolutely doable. And the level of satisfaction I have with my effort after figuring it all out and finally getting it up and running has no words to describe it.
I decided on this because all the bullshit going on with Proton has convinced me that there are no tech companies left out there worth my trust, so I’m taking this for a long spin hoping to be able to migrate my whole family away from the proton family subscription the moment the 2 years I prepaid for end.
It’s not as hard as people make it out to be. Sometimes you just end up in people’s spam folder; that’s life.
Some tips:
- Maintain the same IP for as long as possible - helps with reputation.
- Unless you are in some utopia where your ISP opens port 25 and all the rest, you’ll probably need a VPS. Use a reputable provider. Do your homework.
- Make sure you can transfer your IP through host upgrades as time goes on.
- Make sure your provider will open port 25 and all the rest.
- Make sure your provider will set up reverse dns
- Check that your IP isn’t on any of the credible spam lists. Don’t worry 'bout UCEPROTECT3 - it’s a shakedown.
fwiw, I have been happy with Hetzner + and https://mailu.io/ for my mail server as of late; no affiliation. Going on almost 10 years hosting now.
I’ve been hosting my own email on Hetzner for the last ~10 years. This is good advice. I would add:
- Spend some time reading about and really understanding DKIM, DMARC and SPF. These are NOT optional, you need them if you want your emails to have a chance.
- You will have to play around with your config to get it set up right. That’s fine, just make absolutely sure you don’t ever forward e-mails from unauthenticated users.
- Do not bounce emails.
No you don’t.
I’m pro self-hosting but email is just not critical enough to take on the admin overhead it requires to self-host. Maybe his situation is different and email is more critical in his work/life. If that is the case I would go with the middle ground suggestion provided below which is just to have a custom domain so that switching providers is easy. I would add a FOSS desktop email client so that even when switching providers migration of existing emails is a non-issue.
Almost everyone below downplaying the difficulty is suggesting the use of a vps as a way to “make it easier” or make it work at all. But that defeats the purpose as his main complaint is corpos doing corpo shit. Last I checked VPS providers aren’t mom and pop shops so that’s just kicking the can further down you tech stack. You are still at the behest of your VPS provider and doing significantly more admin task just for email.
I personally believe the opposite email is so critical that it is not worth trying to self host.
I do however agree that having your own domain is perfect for it though. Having your own domain name is the way to go, just make sure whoever you go with offers a wild card option so you can make up unique names for everything, you get no spam. And if you change hosts for whatever reason you do not need to setup each email again.
make up unique names for everything, you get no spam
Well, you know where the spam came from.
I do this with mine, but frequently it confuses customer service people and others. “wait, your email is progressive@ssfckdt.org? do you work for us?”
I’ve had only one business ask me this once but probably because I rarely have to interact with people for it.
I did consider this when I got the “throw-away” email domain, made it something that’s easy for people to understand.
It’s probably easier that, if you have to verbally dictate someone an email, you sneak a clue about them in there without it being super obvious. Maybe an abbreviation or a number. Like maybe you call it “gym2@” and not “nameofgym@”. Probably better overall all things considered, and as long as it’s unique it doesn’t really matter.
I rarely talk to people about my email so I have a scheme (pagename_randomlocalslang_threenumbers@reannlegge.ca) when signing up for poop I started using that when I needed a little longer with a “free trial” of something sure I could probably have just gone pagename2@reannlegge.ca, but I wanna say HostHero or some page had rules about how long a email addresses had to be. The only times I have used the businessname@reannlegge.ca was when I deal with the business in person, the first time I had to create the address on the spot and I did not yet have a rondomizer built that I could just wip out and run on my phone, I had to be at home, and the second time it was because I was buying furnature and I knew I was only going to be getting spam on it after the receipt came through so I new it was going to be blocked right away so even if they sold my address no one was going to work out my email address scheme.
I get next to no spam.
Domain registrars are also not mom and pop shops either and neither is the IANA or Internet Service Providers assigning IPv4 addresses… Not totally disagreeing with what you said, but it’s large organizations all the way down.
As someone who used to manage a mail server, I would not do it ever again. Well, Installing and configuring them IS the fun part. Managing them, making sure the domain is not blacklisted, checking spamhaus, getting asked why I don’t reply their email while it was google who dump the email to the spam folder was not fun.
Absolutely go ahead!
My recommendation would be to do so on a VPS, don’t do it with your home IP address.
Today there are some all in one solutions, but I prefer the old hands on at all levels approach.
This is my personal experience: https://wiki.gardiol.org/4-e-mail-hosting (no ads, no monetization, no AI).
I installed and setup postfix and dovecot and dkim dmark, the works.
One more advice: DNS records are key, do not skip them, everything depend on proper DNS setup in the email world.
Pick mox or Stalwart. Both are one program that does everything (sending, mailboxes, spam checks, admin page), so you skip the Postfix-and-Dovecot pile.
If you want the simplest, mox. Its quickstart asks for your address and prints the DNS records to copy. It’s MIT-licensed though, not GPL. If the licence matters most, Stalwart is AGPL-3.0, the closest to what you asked for (a few extras are paid, the mail server isn’t).
The catch is the same for either: a home connection usually has port 25 blocked and Gmail distrusts home addresses. So run it on a small rented server (a VPS), where it’s still your software and your mailboxes. Before paying, ask the provider two things: will it open outgoing port 25, and can you set the IP’s reverse DNS name to mail.yourdomain.
Done looks like: a test to mail-tester.com scores well, and a message to a Gmail address lands in the inbox. Keep your current mailbox until a week of mail has gone through cleanly.
A trick I discovered this month. Use the smtp_address_preference flag on postfix to send over IPv6.
If you run your home IP address through the blocklist check on MX Toolbox, you’ll find that almost every home (CPE) IPv4 block is blacklisted. It’s simply not the case for IPv6, and all the big players accept mail over v6.
Apart from that, just make sure to jump through the TLS, DKIM, SPF hoops so other servers don’t reject you. The MX toolbox free stuff has enough to test and verify that it’s right.
I don’t bother with traditional spam filtering. The SPF/DKIM checks catches enough of it.
Go for it. More people should. I’m running postfix+dovecot combo on a VPS running Debian.
As others have already mentioned, you’ll need a server with static public IP address and a way to change DNS PTR record for it, so in practice for majority of people that means a VPS from (preferably) a reputable vendor. Then you’ll need to set up DNS records for your domain, MX and SPF are sufficient. DKIM and DMARC are nice to have, but not strictly speaking needed, at least for now.
When configuring your SMTP service make sure that no one other than intended users can send mail trough it. That’s pretty much the most important thing if you want to stay out of blocklists. You’ll still end up in a few and it needs some manual work to resolve, but the longer you run your own server the fewer false positives there will be.
Some will suggest mailcow or some other ‘all in a box’ service. They very likely work and may even work better than good’ol postfix, but I’d still recommend postfix (or exim, if you lean that way) because they really teach you the ropes and also they support maildir format for mailbox storage which makes it pretty trivial to move and backup stuff between installations as needed.
When you get the setup running make absolutely sure your backups are in order. Email is so important for a lot of things that losing your inbox may be a costly mistake. Also set up some sort of server monitoring so that you’ll get alerts if something is not right. Email is pretty resilient, it can easily handle couple of hours downtime from a server, but the longer your downtime is the more you risk of lost emails (senders will get a notification that delivery failed, but it’s up to them to react for it).
There’s a handful of different parts to figure out, but nothing is really that difficult. Sure, you’ll need to understand how email works under the hood and the whole stack is more complex than throwing a jellyfin docker image on your personal server but it’s very much doable. Have fun!















