How to Set Up a Mailcow Dockerized Mail Server on Ubuntu 24.04
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.compointing to your Server IP. - MX Record:
yourdomain.compointing tomail.yourdomain.com(Priority 10). - Reverse DNS (rDNS / PTR): Configured with your server hoster to match
mail.yourdomain.com.
2. Install Docker & Git
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git docker.io docker-compose
sudo systemctl enable --now docker3. Clone Mailcow Repository
Clone the official mailcow repository into /opt/mailcow-dockerized:
cd /opt
sudo git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized4. Generate Configuration
Run the interactive configuration generator:
sudo ./generate_config.shEnter your fully qualified mail hostname (e.g. mail.yourdomain.com) and select your timezone.
5. Pull Images and Start Mailcow
sudo docker-compose pull
sudo docker-compose up -d6. Firewall Configuration
Open required mail ports in UFW:
# 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/tcp7. Access Admin Web UI
Open https://mail.yourdomain.com in your browser. Default login:
- Username:
admin - Password:
moohoo(Change immediately upon first login!)
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.