Install mailcow using mailcow: dockerized (Tutorial)

Mailcow is a user-friendly mail system for sending, receiving and managing email, email users and more.

Its only officially-supported install method uses the consistency and ease of Docker and dockerized services, so this can be done quickly if you already have a functional Docker setup in place. That said, here are some prerequisites for Mailcow, as well as the steps to follow to get Mailcow up and running.

Prerequisites

  • Docker and docker-compose installed and configured, as well as docker-compose
  • A-Name record for email server address
  • FQDN chosen and configured (can use the same address as above)
  • MX Record for primary domain
  • SSL Certificate for mail server
  • Required ports open
  • At least 3GB of RAM available on your VPS

Setting Up Mailcow

Assuming Docker is all setup and ready to go, the installation process is fairly straightforward. Docker makes things a lot simpler, as packages and dependencies are self-managed within each docker image or package.

First, we’ll need to ensure that the unmask settings for the operating system are correct. Typically, this is already the case, but it never hurts to check.

umask
0022

You’ll want to run the umask command, and if it isn’t 0022, modify your systems umask settings to match that.

Next, we’ll switch to the /opt folder and create our working directory. Git must be installed for this part, although most linux-based operating systems have it available in their default repository, if not installed already.

cd /opt
git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized

Now, we will generate the configuration file that mailcow will use. Luckily, there’s a simple-to-use script that allows us to just enter a few pieces of information to get this going.

./generate_config.sh

At this point, the script will ask for your FQDN. Keep in mind, this is different than your mail domain. For instance, if you plan on using emails that use the domain example.com, you might use the FQDN of mail.example.com. It will also ask you for your Time Zone. It’s perfectly fine to use the default (hit enter), or you can choose your local timezone as explicitly listed as the TZ database name here. I chose the America/Los_Angelestime zone as I am in the Pacific Standard time zone.

If you are using a reverse proxy, you’ll need to further modify the configuration file as necessary to accommodate for the default 80 and 443 ports to be already spoken for by your web server. Otherwise, the default configuration file that is generated is fine for a standalone server.

Launch the Mailcow Docker Compose

Now, we’ve completed our setup. We just need to actually pull and launch the docker images that will run our Mailcow instance. While still in the /opt/mailcow-dockerized folder, we’ll run the docker-compose commands.

docker-compose pull
docker-compose up -d

The -d flag causes the mailcow docker installation to run detached from the primary window, allowing it to continue running after the current session ends. Be patient, as this step can take some time. It’s pulling in and configuring all the different parts of the docker configuration that helps us run our Mailcow install.

Setting Up Emails

Nice! We’re up and running. Let’s get an email address set up and working.

Log into your new mailcow install by navigating to the secure url for your FQDN. Using our previous example, if your FQDN is mail.example.com, you’d want to point your browser to https://mail.example.com. The default username and password for your new Mailcow install is admin and moohoo, respectively.

First, we’ll need to add our domain. So after logging in, navigate to the configuration tab, and click on the Mail Setup link.

Mail Config

Next, we’ll click the button to add a domain.

Add Domain

Fill out the domain name. That is, the root domain that we want to use for our email addresses. The defaults are fine, unless you specifically know something you need to change for your needs. To finish, click the Add domain and restart SOGo button. This adds the domain and restarts the service that manages it at the same time.

Domain Details

Next, click over to the Mailboxes tab.

 

Click Add mailbox

Add Mailbox

Enter the username, select the domain (if you’ve aded more than one), enter the name for the user, the quota (enter 0 for no size limit), and then create/generate a password. Finally, click Add.

And that’s it! You’ve setup mailcow, created an email address, and now are ready to use your email address to send and receive emails. Log out of the Admin user and navigate to your.mailhost.domain/SOGo and use the email address and password you used. Alternatively, you can log into any standard email client using POP3 or IMAP4 protocols as you normally would.