Introduction
Mailcow is a powerful, open-source mail server suite based on Docker, designed to provide a complete email solution with modern features like spam filtering, antivirus scanning, and a user-friendly web interface. In this guide, you'll set up your own secure and fully functional mail server using Mailcow on a Debian or Ubuntu system.
Prerequisites
A fresh Debian 11+ or Ubuntu 20.04+ Linux KVM server (Containers and Storages are not supported)
At least 6 GB RAM, 2 CPU, and 30 GB storage
A fully qualified domain name (FQDN) like server.domain.tld
Proper DNS records (A, MX, CNAME)
“A” record must point to server’s IP address;
“MX” record must point to server’s hostname.
1. “CNAME” record value “autodiscover.server.domain.tld” pointing to your server’s hostname.
2. “CNAME” record value “autoconfig.server.domain.tld” pointing to your server’s hostname.
Root SSH access
Opened 25 port.
Installation
1. Update your system:
sudo apt update && sudo apt upgrade -y
2. Install Docker & Docker Compose
sudo apt install -y curl gnupg2 ca-certificates lsb-release software-properties-common
curl -fsSL https://get.docker.com | sh
sudo apt install -y docker-compose
3. Clone Mailcow repository
cd /opt
sudo git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
4. Configure Mailcow
4.1. Generate the Mailcow configuration:
./generate_config.sh
4.2. When prompted, enter your server’s hostname (example: server.domain.tld)
4.3. Check if timezone is set correctly and hit enter.
4.4. If you want to use master branch, continue by clicking enter.
5. Run Mailcow
sudo docker compose pull
sudo docker compose up -d
Done! Now you have Mailcow Mail Service installed. Access admin web interface through the browser and write in the hostname you have provided earlier. If everything is correct, you should be able to see this page.
https://server.domain.tld/admin
Default credentials:
User: admin
Password: moohoo
Configuration
1. To create new email boxes, first you need to add a domain. To complete this task, in the dashboard, go to “E-Mail” -> “Configuration”.
2. Click on “+ Add domain” and configure it for your needs.
3. After adding the domain, click on “Edit” and copy created DKIM record and insert it into your domain’s DNS records.
Name: dkim._domainkey.DOMAIN.TLD
Value: (insert the value from the box).
4. To create a new email box, go to “Mailboxes” -> “Mailboxes”. Create the mail box by clicking on “+Add mailbox”. After creating the email box, users now will be able to access it through your provided hostname via Webmail: http://server.domain.tld
5. Before adding new domain to have it’s SSL certificate issued, you will need to create these records:
“MX” record pointing to your server’s hostname;
“CNAME” value “autodiscover.domain.tld” to your server’s hostname;
“CNAME” value “autoconfig.domain.tld” to your server’s hostname.
If you add these records after adding domain to Mailcow, re-run “acme-mailcow” script in SSH:
docker compose restart acme-mailcow
During the Mailcow installation, SSL certificate is automatically issued for Webmail and Dashboard.
Conclusion
The Mailcow installation and configuration completed successfully, with all core services running and secured using Let's Encrypt SSL. You can now access the Mailcow web dashboard at https://server.domain.tld (your existing hostname) to manage mailboxes, domains, and mail flow settings. From the dashboard, administrators can monitor system status, configure DNS records, and control anti-spam and quarantine features.