Back to all guides
DevOps & Cloud

How to Set Up a Mailcow Dockerized Mail Server on Ubuntu 24.04

5 read2026-08-31

Mailcow (mailcow: dockerized) is a modern, enterprise-ready email suite combining Postfix, Dovecot, SOGo Webmail, Rspamd spam filtering, and automated Let's Encrypt certificates into an easy-to-manage Docker environment.

1. Prerequisites & DNS Setup

Before starting, ensure your DNS records are configured with your domain provider:

  • A Record: mail.yourdomain.com pointing to your Server IP.
  • MX Record: yourdomain.com pointing to mail.yourdomain.com (Priority 10).
  • Reverse DNS (rDNS / PTR): Configured with your server hoster to match mail.yourdomain.com.

2. Install Docker & Git

bash
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git docker.io docker-compose
sudo systemctl enable --now docker

3. Clone Mailcow Repository

Clone the official mailcow repository into /opt/mailcow-dockerized:

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

4. Generate Configuration

Run the interactive configuration generator:

bash
sudo ./generate_config.sh

Enter your fully qualified mail hostname (e.g. mail.yourdomain.com) and select your timezone.

5. Pull Images and Start Mailcow

bash
sudo docker-compose pull
sudo docker-compose up -d

6. Firewall Configuration

Open required mail ports in UFW:

bash
# Web UI / ActiveSync / Webmail
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

# SMTP / Submission
sudo ufw allow 25/tcp
sudo ufw allow 465/tcp
sudo ufw allow 587/tcp

# IMAP / POP3
sudo ufw allow 993/tcp
sudo ufw allow 995/tcp

7. Access Admin Web UI

Open https://mail.yourdomain.com in your browser. Default login:

  • Username: admin
  • Password: moohoo (Change immediately upon first login!)
KVM Linux VPS

Looking for the right Linux VPS?

Put your project into practice right away: Our KVM VPS provide full root access, lightning-fast NVMe storage, and reliable KVM isolation. Flexible prepaid billing with no subscription and personal Discord support.

Full Root Access (SSH)
Datacenter NVMe SSD
4+ Tbps DDoS Protection
100% Prepaid (No Subscription)