Tutorials

How to Configure Mailcow: Dockerized Email Server on Ubuntu VPS (2026)

How to Configure Mailcow Dockerized Email Server on Ubuntu VPS (2026) - CpanelFree Guide
Written by Blog

Quick Answer: Mailcow Dockerized is the gold standard open-source email server suite. To deploy it on an Ubuntu 24.04 VPS: 1) Provision a 2 vCPU / 4GB RAM VPS with PTR reverse DNS configured, 2) Install Docker and Docker Compose, 3) Clone Mailcow repo from GitHub, 4) Run ./generate_config.sh to configure your hostname (mail.yourdomain.com), and 5) Execute docker compose up -d to launch the complete mail stack with automated Let’s Encrypt SSL.

Minimum System Requirements for Mailcow

  • Operating System: Ubuntu 24.04 / 22.04 LTS or Debian 12
  • RAM: 4GB minimum (or 2GB with SKIP_CLAMAV=y and SKIP_SOLR=y in mailcow.conf)
  • Disk: 30GB+ NVMe SSD storage
  • Network: Open outgoing Port 25, 465, 587, 993, 80, 443 with a clean IP address.

Step 1: Install Docker & Docker Compose on Ubuntu

sudo apt update && sudo apt install -y curl git apt-transport-https ca-certificates
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

Step 2: Clone Mailcow and Generate Configuration

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

Enter your Fully Qualified Domain Name (e.g. mail.yourdomain.com) and select your timezone.

Step 3: Launch Mailcow Docker Containers

sudo docker compose pull
sudo docker compose up -d

Step 4: Configure DNS Records for 100% Deliverability

Add these DNS records in your domain control panel:

  • A record: mail.yourdomain.com -> VPS Public IP
  • MX record: @ -> mail.yourdomain.com (Priority: 10)
  • TXT (SPF): v=spf1 mx a:mail.yourdomain.com ~all
  • TXT (DMARC): v=DMARC1; p=quarantine; pct=100;

Fine-Tuning Mailcow Docker Resource Consumption

By default, ClamAV antivirus and Solr search indexing consume over 2.5GB of RAM. On a resource-constrained 2GB VPS, optimize mailcow.conf before booting:

# Disable heavy memory daemons in mailcow.conf
SKIP_CLAMAV=y
SKIP_SOLR=y

This reduces Mailcow’s idle memory consumption down to under 750MB, leaving sufficient resources for Postfix, Dovecot, and Nginx reverse proxy containers.

Backing Up Mailcow Docker Volumes via Automated Script

# Execute automated Mailcow backup script
BACKUP_LOCATION=/var/backups/mailcow ./helper-scripts/backup_and_restore.sh backup all

Essential Post-Installation Hardening for Mailcow Dockerized

  1. Enable Two-Factor Authentication (2FA): In the Mailcow admin dashboard, require TOTP two-factor authentication for all administrative accounts.
  2. Configure Automated Backup Cron: Set up a daily cron job running backup_and_restore.sh to push encrypted volume archives to an offsite S3 or SFTP server.
  3. Fine-Tune Rspamd Greylisting: Configure Rspamd greylisting thresholds to delay unknown connecting mail servers by 5 minutes, eliminating 90% of automated botnet spam blasts.

How does Mailcow handle Let’s Encrypt SSL renewals?

Mailcow includes an integrated ACME container (acme-mailcow) that automatically checks domain DNS records, requests Let’s Encrypt multi-domain certificates, and reloads Postfix/Dovecot every 60 days without downtime.

Deploy Scalable Cloud Servers on CpanelFree

Deploy high-speed NVMe cloud instances with root SSH access, dedicated IP options, and 24/7 uptime monitoring on CpanelFree.

Explore Cloud Servers

Frequently Asked Questions

How do I access the Mailcow admin UI?

Open your web browser and go to https://mail.yourdomain.com. Log in using default credentials: Username admin and Password moohoo (remember to change it immediately!).

Configuring Mailcow Multi-Domain Relaying and Transport Maps

If your VPS hosting provider blocks outbound port 25, Mailcow features a built-in Routing / Transports menu in its admin UI. You can enter an external SMTP relay host (such as smtp-relay.brevo.com:587) with authenticated credentials, routing all outgoing mail through the relay while storing incoming IMAP mailboxes locally.

Pro Sysadmin Tip: Upgrading Mailcow Dockerized in 1-Click

To update your entire containerized mail stack, navigate to /opt/mailcow-dockerized and execute ./update.sh. The script automatically pulls updated container images and applies database schema migrations safely.

Deploying Mailcow Dockerized delivers an enterprise-grade private email hosting infrastructure with modern webmail, automated spam filtering, and complete data privacy.

Automating Mailcow SSL Renewal and Certbot Monitoring

Mailcow’s integrated ACME daemon automatically requests and renews multi-domain Let’s Encrypt certificates every 60 days. You can monitor certificate status and force immediate renewal in the Mailcow admin UI under Configuration > SSL Certificates.

How many mailboxes can a 4GB RAM Mailcow server host?

A standard 2 vCPU / 4GB RAM Cloud VPS running Mailcow can comfortably support over 100 active business mailboxes with full spam filtering and groupware synchronization.

Additionally, Mailcow includes native DKIM key generation in its web interface, automatically creating 2048-bit DNS TXT records for all hosted domains.

With automated Let’s Encrypt renewals, Rspamd anti-spam, and isolated Docker microservices, Mailcow offers the most robust open-source mail server platform available for Linux sysadmins.

Regularly maintaining your Mailcow Docker containers and monitoring mail queue status via docker compose exec postfix-mailcow mailq guarantees high deliverability and uninterrupted email service for all your custom domains.

By implementing proper DNS records, TLS certificates, and resource monitoring, your self-hosted Mailcow server will deliver enterprise-grade performance and reliability across all mail domains.

About the author

Blog

DevOps architect and Linux sysadmin specializing in server hardening, OpenLiteSpeed performance optimization, and free cloud hosting infrastructure.

Leave a Comment