Install Mailcow on Ubuntu Server

Mailcow is one of the best FOSS mail servers. It runs on Docker, making it incredibly easy to install and manage. This means that it benefits from Docker’s containerization features, such as portability, easy updates, and simple scaling. With Mailcow, you can manage a full mail server stack without having to deal with complicated configurations or software dependencies. It’s designed to be user-friendly, reliable, and offers all the essential features that modern email users require.

Mailcow provides an intuitive web interface for managing mailboxes, domains, spam filters, and more. It includes support for SMTP, IMAP, POP3, and all the essential protocols needed for mail servers. Additionally, Mailcow integrates popular open-source software like Dovecot, Postfix, and Rspamd, making it a comprehensive solution that is highly customizable and robust. Furthermore, its strong security features, such as built-in spam filtering, anti-virus protection, and two-factor authentication, ensure a safe and reliable email experience.

Another standout feature of Mailcow is its active community and constant updates. Being an open-source project, it is continuously improved by developers around the world. This makes it one of the most up-to-date and feature-rich solutions available for those seeking a self-hosted mail server solution.

Configure the firewall

Before installing Mailcow, make sure that thies ports are open on the Firewall:

ServiceProtocolPort
Postfix SMTPTCP25
Postfix SMTPSTCP465
Postfix SubmissionTCP587
Dovecot IMAPTCP143
Dovecot IMAPSTCP993
Dovecot POP3TCP110
Dovecot POP3STCP995
Dovecot ManageSieveTCP4190
HTTP(S)TCP80/443

Installing Mailcow on Ubuntu Server

After installing Ubuntu Server, steps down to install and configure Mailcow.

Install and Configure UFW

To secure your server with UFW, first, allow the required ports:

sudo ufw allow 22,25,465,587,143,993,110,995,4190,80,443/tcp

Then, reload UFW:

sudo ufw reload

Now, enable UFW and ensure it starts automatically on boot:

sudo ufw enable ; sudo systemctl start ufw

Install Mailcow

1. Update the System and Reboot:

After installing Ubuntu, update your system, install jq and reboot with the following command:

sudo apt update ; sudo apt full-upgrade -y ; sudo apt install jq -y ; sudo reboot

2. Install Docker and Docker Compose:

Install Docker Compose with the following command:

curl -sSL https://get.docker.com/ | CHANNEL=stable sh ; sudo apt install docker-compose-plugin

3. Install Mailcow:

Now that Docker Compose is installed, let’s install Mailcow:

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

4. Generate Configuration:

Generate the configuration file. Use a Fully Qualified Domain Name (FQDN) as the hostname when prompted (e.g., host.domain.tld):

sudo ./generate_config.sh

5. Modify the Configuration (if necessary):

If you need to make any changes to the configuration, use the following command:

sudo nano mailcow.conf

6. Download and Start Docker Containers:

Now, pull the necessary Docker images and start the containers:

sudo docker compose pull
sudo docker compose up -d

That’s it!

You’ve successfully installed Mailcow on your server! You can now access the web interface by navigating to https://<your-domain>/admin

Default Login:

  • Username: admin
  • Password: moohoo

What’s Next?

After installing Mailcow and changing the default login credentials, consider the following next steps to enhance your Mailcow setup:

  • Add your domain under E-Mail > Configuration.
  • Configure Fail2ban parameters under System > Configuration.
  • Enable two-factor authentication for every user.

Video Walk-through

Leave a Reply

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