CODEX
Tech Choices for Self-Hosting E-Mail
Taking Steps Towards Enhancing My Personal Life’s Privacy

According to TechJury, as of 2020, GMail owns 43% of the e-mail services market share which equates to over 1.8 billion users. There’s a good reason for this as Google runs what’s questionably the best e-mail service out there with a long and distinguished list of associated integrated features that make all of our lives easier.
Part of the reason why I still recommend GMail to my friends and also GSuite (or Google Workspace… they keep changing names) to all of my clients is because there’s pretty much no way for anyone not dedicated to running e-mail services to even come close to Google given the inherited user familiarity, manageability, and deliverability of GMail. In fact, even someone like myself who started their career as an “E-Mail Administrator” have grown to become a long-time customer of GSuite because it really allows technical folks to focus on more important things than to troubleshoot and maintain an e-mail server which can be a tedious up-taking.
However, recently, I have been thinking about how I might potentially de-google a portion of my personal life by hosting my own e-mail and file sharing services once again in exchange for more flexibility and privacy; something I haven’t really done since Google Apps (GSuite/Workspace’s former name) came to life in the mid to late 2000’s. Of course, right off the bat, I was hoping there are easier solutions now-a-days just as how coding has become much simpler over the years with all the growing amounts of opensource libraries and such. Unfortunately, while there are options out there, none of them seem to come close to meeting my needs. Here are some of the better options that are out there which I have looked at but fall short from my perspective when it came to the choice of technologies:
- iRedMail — Docker all-in-one is not production ready and SoGo is too heavy for me while falling short compared to NextCloud in many non-e-mail aspects.
- MailCow — Multiple containers for just mail and uses SoGo as well :(
- Mail-In-A-Box — No official docker image and RoundCube… yuk… Plus Mail-In-A-Box needs to manage your DNS…. I get why but I want to manage my own DNS for more reasons than I can cover here.
As you can tell from the above, while each of them have their own perks and comes with a simple web interface to administer your e-mail service, they all fell short when it came to the choice of components for me and none of them were really “easy” enough to setup to offset the sub-par choices. Plus, I don’t mind doing everything from the terminal so whether or not there’s a web interface to manage my mail service is almost irrelevant.
As such, I decided to use some of my knowledge from all the years of working with e-mail servers and set out to build a solution of my own as a fun side-project. During this process, I evaluated and built each component into 4 logically separated docker containers:

And derived the following lists of technology choices that make up my custom solution.
Docker Host:
- Let’sEncrypt — SSL used by all containers for https, imaps, and smtps
Reverse Proxy:
- jwilder/nginx-proxy— Stock Docker image automating the reverse proxying of web, webmail, and NextCloud
Web container:
- Niginx — Serving mta-sts
Mail/WebMail container:
- Postfix — Smtp and smtps
- Postgrey — Grey listing
- OpenLDAP — Authentication
- SASL — Authentication
- AMavis — Anti-Virus
- ClamAV — Secondary Anti-Virus
- SpamAssassin — Spam Filter
- OpenDKIM — DKIM signing
- Dovecot — IMAPs
- Rainloop — WebMail
- Nginx — to serve Rainloop
- postfix-policyd-spf-python — SPF
- postfix-mta-sts-resolver — MTA-STS
- DNS Configs — SPF, DKIM, DMARC, MTA-STS
- Test mail server with checktls.com:

NextCloud Container:
- OpenLDAP Auth (Client)
- Calendar
- WebMail — So that calendar can be integrated with e-mail
- Contacts
- File Storage
- Video Conferencing
- Web-Based Office
*Note: The NextCloud container is actually 2 containers in reality. One for web and one for DB.
That’s it! Based on the above setup, I have been happily self-hosting my own personal e-mail service covering all the features that I use with Google. The only thing that might be missing is activesync for those who actually want to use Outlook related products but I don’t and I am perfectly happy with Geary and the super lean and fast Rainloop for web mail. Perhaps, the only not immediately fixable downside with what I have so-far is that as of now, recipients of my e-mails may have to mark my first e-mail as “not spam” or have my e-mail address added to their contact list first before my e-mails start to directly land in their inboxes instead of their spam folders but I guess this is a small price I am willing to pay to have full-control over my data. Who knows… as my sender reputation increases and maybe some further tweaking of what I have, this may no longer be an issue either.

