August 29th, 2024

Hosting my own Email server

banner

Hosting your own email server isn’t something even all self-hosting gurus recommend because it’s really tough to get right. Still, I wanted to understand it better, so I decided to set up my own email server for my eebs.fi domain.

I had some experience from work, so I thought I’d give it a shot. My first challenge was dealing with ISPs and cloud providers, which often block email traffic by default to prevent spam and bad reputation. I managed to find one that does block it by default but unblocks it if you ask nicely. I got a small VM from Linode and got to work. I chose Postfix for sending and receiving emails, and Dovecot for reading them via IMAP—tools I was somewhat familiar with. I went with Ubuntu as my OS because I’m comfortable with it and I'm boring like that.

I started off by reading "The Book of Postfix" and following its instructions for a basic setup. I think the book is a must-have if you want to really understand what you're doing. I’ve tried using online documentation and googling, but for some reason, I couldn't find that much clear, comprehensive information. The book breaks down most of the settings well, even if it's a bit outdated (it even has a section on setting things up with dial-up internet…).

Setting it up

I got Postfix to accept mail locally, then from external sources, and finally, to send mail from the server to the internet. Success! It took a few hours, but the configuration file wasn’t even that big or complicated. My biggest hurdle was dealing with blocked ports. At first, I thought Linode hadn’t opened port 25 because I couldn’t connect, but it turned out my ISP was blocking it. Figuring that out took way longer than I’d like to admit.

Dovecot was much easier to configure. All I really had to do was set the mail location, enable SMTP authentication for Postfix, and set up SSL certificates. That was enough to get IMAP working. I tested everything on the command line and with Thunderbird, and it worked.

Getting it all up and running was really satisfying, but this is just the bare minimum setup. I haven’t looked into the security aspects or spam filtering yet, which I’ll definitely need to address if I plan to use this server seriously.

Use Case

Right now, the contact form submissions at eebs.fi/contact get sent to this server (via gunmail for now), as well as any email to contact@eebs.fi. I’ve got it set up to notify my phone instantly.