Running your own email server

Email was one of the earliest services for communication via the internet. But, hosting such a simple service is quite complicated nowadays. In this post I have documented how I set up an email server for a business quickly and easily.

Why would someone need that?

There already exists several established players for simply sending and receiving emails, but there could be reasons why you would want to host your own: – Privacy If you are dealing with financial data, or in general don't want Google, Microsoft, etc. to snoop in over your emails – Several Users If you have more than a couple users on your domain name, hosting emails gets expensive, and that too quickly. Hosting it on your local server or a VPS is much cheaper than paying for GSuite if not using its other services. – Control The Internet is becoming quite centralized especially with messaging (WhatsApp, Signal, iMessage, etc.). Email by its virtue is meant to be distributed making it ideal for messaging. [Will talk about encryption further]

Choosing an email server

Upon quick googling we can find that there are several email server solutions. Basically a complete package that is easy to run and maintain. After a lot of testing of different solutions and checking feature parity, I decided on using Power Mail-in-a-Box {a fork of Mail-in-a-box — an already popular solution} for setting it up for a business. A couple of reasons for choosing it, over several others:

P.S. By default, all emails sent to the same domain are just routed internally.


There are several ways to host your email server. The best is to just repurpose any old system, with a replaced drive, adding ram, etc.

An old system's specs which I tested everything on – An Old system with intel i3-2100 or something – 6 GB DDR3 RAM – 500 GB WD Blue SSD (~60 USD) //added extra

You can also deploy on a cloud provider, which I did for the business this was set up for. I recommend Digital Ocean (affiliate link) simply because it's super simple, doesn't block ports and setting up reverse DNS is just as simple as renaming your VM. Although you need to get lucky with an IP that is not blacklisted.

Setting everything up

After installing the OS, setting it up is literally super simple. Follow the steps on the GitHub readme. You will need to configure port forwarding on your router if hosting locally or in your cloud provider's firewall settings.

I would not recommend setting up your box as the DNS server, because if it goes down, your website and even other services will not be accessible publicly. I would hence recommend just copying all records shown and adding it to your DNS server (Cloudflare, Route 53, etc.)

Setup DNS on an external provider

You might not want to open outgoing ports or if ISP might be blocking outgoing email ports (esp. 25), continue reading ahead for a simple solution.

Email Deliverability and SMTP relays

There are several reasons why your emails will be ending up in spam. In fact, you might not even be able to send emails if your ISP is blocking specific ports. For these reasons, SMTP relays come into play.

Basically all your emails from your server are sent to another service which then delivers the email from their servers, which are not blacklisted, ensuring perfect delivery. The emails someone else sends are still delivered to your mailinabox; just sending is handled by such an SMTP relay.

There are several services like AWS SES, Sendgrid, etc. but I really liked Zoho ZeptoMail due to its simple pricing (~ $2 for 10,000 emails), amazing email delivery, and very good customer support which approved our account fairly quickly. There are also several free services like Sendinblue, Mailazy, etc. if sending very few emails/day. After you make an account, setup the required DNS records for your domain; you can configure it in the admin interface as shown below:

PowerMail-in-a-box configure SMTP relay


As I alluded to earlier, you might want privacy and prevent Tech Giants, ISPs from snooping in on your emails. There exists simple solutions like Proton mail to encrypt your emails end-to-end but self-hosting email takes it to another level. Power Mail-in-a-box supports OpenPGP based email encryption and decryption in Roundcube (webmail) itself. It basically ensures that no one can read an email which is sent to you with your public key, and the emails you send could also be encrypted and signed to prove that they are not spoofed. Pretty cool!


Even though I set this up for a business because the free GSuite days are coming to an end, I would not do it for myself. Managing infrastructure is still work, even though mail-in-a-box basically requires almost zero maintenance after everything is configured. For me, I just use Zoho Mail which gives 5 GB free for 5 users on a custom domain, which is generous for individuals & family.

But, for small sized organisations or just for having some fun, this is a legitimate and extremely simple way to set up a mail server. With SPF, DKIM records properly configured and using a relay, even email deliverability is not an issue. The install which I did has been stable and running for a month almost. I will highly recommend setting up backup — its super simple. It supports rsync directly to another remote machine via SSH keys, and it can be configured via the web admin interface itself.

#tutorial #selfhosting

Thanks to Aryan for reviewing this article

If you found any typo, wanna reach out or have a chat – email me at