Setting Up a Self Hosted Email Server

This process actually started in July of this year, but just completed this month. First I took a crack at docker-mailserver, but after I couldn't get that to work I shifted the approach to use mailcow.

Why?

It was a long time coming. I am one to want to self-host everything, and having an email with a custom url looks both professional (and cool). Additionally, I am trying to slowly separate myself from google services; my main email is gmail.

Setting up a new server

After some preliminary research, I discovered that email servers use a lot of RAM, so I set up a new VPS.

https://i.imgur.com/sZA4Uad.png

the new VPS name

Then I went through the setup process for docker-mailserver and roundcube mail client.

sudo docker run -e ROUNDCUBEMAIL_DEFAULT_HOST=[fracturedcode.net](http://fracturedcode.net/) \
-e ROUNDCUBEMAIL_SMTP_SERVER=[fracturedcode.net](http://fracturedcode.net/) \
-e ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE=10M \
-e ROUNDCUBEMAIL_DB_TYPE=pgsql \
-e ROUNDCUBEMAIL_DB_HOST=localhost \
-e ROUNDCUBEMAIL_DB_PORT=6900 \
-e ROUNDCUBEMAIL_DB_USER=roundcube \
-e ROUNDCUBEMAIL_DB_PASSWORD=nope \
-e ROUNDCUBEMAIL_DB_NAME=roundcubemail \
--add-host=
-p 6906:80 -d roundcube/roundcubemail:latest-fpm-alpine

Unfortunately, I couldn't get it working, so I gave up for a month or two.

Mailcow

I looked at some other solutions and settled on mailcow.

Mailcow was super simple to set up. It was a quick look through the configuration file, opening some ports (I had already done that for the other solution), and running a docker-compose command.

Then I had to do some minor setup in the application like DKIM configuration and security.

https://i.imgur.com/H0lmKRt.png

What the mailcow dashboard looks like

Mailcow by default comes with a webmail program called SOGo, which is kind of like RoundCube. I do think I prefer roundcube. I will either replace SOGo with RoundCube or remove webmail entirely.

https://i.imgur.com/XuSxBkw.png

The SOGo interface

I would definitely recommend mailcow for a self-hosted email solution. I would say it is easier to use than docker-mailserver, and it also gets regular updates and support.

Email me @ gabe@fracturedcode.net

-Gabe