Set Up Your Own Email Server In Ubuntu

There are plenty of reasons you’d want to run your own mail server. Privacy, security, and customization are just a few.

Putting together a custom mail server is a huge pain. It’s really not something that you’d want to do, let alone maintain. Thankfully, there are several nice options that provide turn-key solutions. This guide is going to focus on Mailcow.

Mailcow provides absolutely everything that you need for an email server pre-configured and bundled in a convenient Docker container. It even has a management interface for you to easily stay on top of your server.

This guide doesn’t cover absolutely everything involved in running a professional mail server; there’s just too much. You will need a web hosting company and a domain name. You will have to configure your DNS records on that web host. Since that configuration is specific to the company, there’s no way to cover it here.

Mailcow runs within a Docker container. If you’ve never heard of Docker before, don’t worry; you don’t need to be an expert to follow this guide. Just know that Docker containers act kind of like partial virtual machines. They create separate compartments where you can install software without it interfering with the rest of the system. That’s what allows Mailcow to arrive already set up and pre-assembled.

Install the Docker Repository

In order to ensure that you have the most up-to-date version of Docker, it’s best to install the Docker repository on Ubuntu. Start by grabbing the dependencies that you’ll need.

Now, use cURL to grab Docker’s GPG key and add it.

Finally, add the repository to Ubuntu.

Install Docker with Apt

Update your package listing and install Docker. Docker recommends specifying the version that you want to install on production systems. This just helps guarantee stability.

After running apt-cache, you’ll see the version listed. You can pick the latest version now, and you’ll stick with that until there is a reason to upgrade beyond it.

Get Docker-Compose

You’re also going to need another tool for Docker. You need to install that too. Unfortunately, the version in Ubuntu’s repositories is really out of date. Since it’s a Python package, it is available with the pip Python package installer. Install Pip and use it to install docker-compose.

With Docker installed and working, you can grab the Mailcow container and install it on Ubuntu. Mailcow is available from Github, so you can just clone the repository. If you don’t already have Git, install that first.

Once you’re in the newly-cloned folder, you can run the script in there that generates your configuration file. Provide your domain name and timezone when you’re asked for them.

Pull The Docker Dependencies

The script won’t take long. When it finishes, use the docker-compose tool that you installed earlier to pull in all of Mailcow’s dependencies.

The download is going to take a while to download everything. Sit back and relax for a bit while it does.

Run Mailcow

After the download finishes, you can start your Mailcow server.

First Run

With the Docker container up and running, you can access your mail server via its web interface. Navigate in your browser to the address that you set up when the configuration script asked you for one.

Log In To Mailcow

The Mailcow interface should pop up. The default admin login credentials are “username: admin, password: moohoo.” Once you log in, Mailcow will ask you to change that username and password.


After you update your login info, you can use the Mailcow interface to set up different email domains and start stetting up users and inboxes. You can now manage everything from Mailcow.


Author: Rohan Dandavate

Public Key: []

Leave a Reply

Your email address will not be published. Required fields are marked *