I’ve mulled over setting up a mail server for years. I tried once 5 years ago, and failed. I don’t know why I wanted to do this, it’s just something I wanted to do. So I did.
I have been on a kick to move a lot of servers to OpenBSD. I love OpenBSD. It is simple (as in simplicity) to use, and I find it easier for me to maintain more than other operating systems. I also liked having OpenSMTPD built in. I read a lot of articles, and found none of them really worked. I guess email isn’t a one size fits all thing. I pulled together everything I found and built it my own way. I’m sure the way I did it will be yet another one of those blog posts. Works for me, doesn’t work for you.
Here, I have this documented for myself, and hopefully it can help you. I didn’t understand a LOT of what I was setting up. I really learned a lot as I did it. I would encourage reading the man pages as you go and documentation. There’s a lot of moving parts. I’ll do my best to explain some of this stuff. So here we go!
OpenBSD
First, you need a stable provider. If you want to send mail, you want a VPS provider with good uptime, will give you a clean IP, and of course you want one that will let you install OpenBSD.
One thing that sucks is if you want to send emails to the bigger email companies like Google, Microsoft, Apple, you may find out you are SOL only when you have everything set up. You can plug your IP into a site like MXToolbox and see for yourself if you have a clean IP, but these other companies have their own blackbox lists and you probably won’t find out until you send your first email to them and get the sad bounce. Vultr could be a good option, but you have to ask for permission to open the right ports. This usually means you won’t get blocked by the big email companies. Currently, I am blocked on RamNode’s network. Hoping they can resolve the issue, otherwise I have to move everything and try again myself.
Initial Setup
Once your system is up and running, you’ll want to do your syspatches and what not. You can do any other tweaking you might like here. Assign your IP addresses, go set your A and AAAA records as well as your PTR (or rDNS) records. I set these records:
A - mail.example.com CNAME - smtp.example.com CNAME - imap.example.com