Deploy a full-featured self-hosted mail server with Mailcow on Docker.
Category: Mailcow
Prerequisites
- Ubuntu 22.04 LTS server with at least 2GB RAM
- A domain name with DNS control
- Ports 25, 80, 443, 465, 587, 993, 995, 4190 open in firewall
- Docker and Docker Compose installed
DNS Records Required
# MX record
@ MX 10 mail.yourdomain.com
# A records
mail A your.server.ip
# SPF
@ TXT "v=spf1 mx ~all"
# DMARC
_dmarc TXT "v=DMARC1; p=quarantine; rua=mailto:admin@yourdomain.com"
Install Mailcow
# Clone Mailcow
cd /opt
sudo git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
# Generate config (answer prompts for your hostname)
sudo ./generate_config.sh
# Pull and start
sudo docker compose pull
sudo docker compose up -d
Access the Admin Panel
After startup, access the web UI at https://mail.yourdomain.com. Default credentials:
- Username: admin
- Password: moohoo
Change the admin password immediately after first login.
Add a Domain and Mailbox
- Go to Email → Domains → Add Domain
- Go to Email → Mailboxes → Add Mailbox
- Configure DKIM under Email → Configuration → ARC/DKIM Keys
Useful Management Commands
# Check container status
cd /opt/mailcow-dockerized
sudo docker compose ps
# View logs
sudo docker compose logs --tail=50 -f
# Restart all services
sudo docker compose restart