Software & Configuration

Mailcow

Install a complete self-hosted mail server with Mailcow Dockerized, SMTP, IMAP, webmail, anti-spam and DKIM included

Mailcow Dockerized is a complete mail server stack running entirely on Docker. It includes Postfix (SMTP), Dovecot (IMAP), SOGo (webmail), Rspamd (anti-spam), ClamAV (antivirus), automatic TLS and a web admin panel.


Prerequisites

  • Minimum 2 vCPU, 4 GB RAM (6 GB recommended with ClamAV)
  • A dedicated domain or subdomain, e.g. mail.yourdomain.com
  • Ports 25, 80, 110, 143, 443, 465, 587, 993, 995 open on the firewall
  • Reverse DNS (PTR) set to mail.yourdomain.com: essential for email deliverability
  • Docker and Docker Compose installed

Many VPS providers block port 25 by default to prevent spam. Check with DeluxHost support if your VPS has outbound port 25 open before proceeding.


DNS Configuration

Before installing, configure these DNS records for your domain:

TypeNameValue
AmailYOUR_SERVER_IP
MX@mail.yourdomain.com (priority 10)
TXT@v=spf1 mx ~all
CNAMEautodiscovermail.yourdomain.com
CNAMEautoconfigmail.yourdomain.com

DKIM and DMARC records will be configured after installation.


Installation

Clone the repository

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

Generate configuration

./generate_config.sh

The script will ask:

  • Mail server hostname (FQDN): mail.yourdomain.com
  • Timezone: e.g. Europe/Rome

This generates the mailcow.conf file.

Start Mailcow

docker compose pull
docker compose up -d

The first startup takes several minutes. Monitor with:

docker compose logs -f

First Access

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

Default credentials:

  • Username: admin
  • Password: moohoo

Change the admin password immediately from Configuration → Access → Admin password.


Creating a Mailbox

  1. Go to Mail Setup → Domains → Add domain
  2. Add yourdomain.com and click Save
  3. Go to Mailboxes → Add mailbox
  4. Fill in username, full name and password
  5. Click Add

DKIM Configuration

DKIM digitally signs outgoing emails, essential for deliverability.

  1. Go to Configuration → ARC/DKIM keys
  2. Select your domain
  3. Click Generate (or use key length 2048)
  4. Copy the DKIM TXT record shown
  5. Add it to your DNS as a TXT record on dkim._domainkey.yourdomain.com

Add a TXT record on _dmarc.yourdomain.com:

v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com; ruf=mailto:dmarc@yourdomain.com; fo=1

Start with p=none to monitor without rejecting emails, then switch to p=quarantine or p=reject once everything is working.


Email Client Configuration

IMAP (incoming mail)

  • Server: mail.yourdomain.com
  • Port: 993 (SSL/TLS)

SMTP (outgoing mail)

  • Server: mail.yourdomain.com
  • Port: 587 (STARTTLS) or 465 (SSL/TLS)

Webmail (SOGo)

  • URL: https://mail.yourdomain.com/SOGo

Maintenance and Updates

Update Mailcow

cd /opt/mailcow-dockerized

# Pull update script
./update.sh

The script handles stopping containers, pulling new images and restarting.

Backup

# Backup all data
cd /opt/mailcow-dockerized
./helper-scripts/backup_and_restore.sh backup all

Backups are saved to /var/mailcow_backups/ by default.

Restore

./helper-scripts/backup_and_restore.sh restore

Useful Commands

# Check all container status
cd /opt/mailcow-dockerized
docker compose ps

# View logs for a specific service
docker compose logs -f postfix-mailcow
docker compose logs -f rspamd-mailcow
docker compose logs -f dovecot-mailcow

# Restart a single service
docker compose restart postfix-mailcow

# Restart all Mailcow
docker compose restart

Rspamd (Anti-spam)

Rspamd is the anti-spam engine. Access its web interface at:

https://mail.yourdomain.com/rspamd

The password is in mailcow.conf:

grep RSPAMD_PASSWORD /opt/mailcow-dockerized/mailcow.conf

From the Rspamd interface you can view scores of analyzed emails, whitelist/blacklist senders and adjust spam thresholds.


Deliverability Check

After configuration, verify your mail server with:

A score of 10/10 on mail-tester is achievable with Mailcow if SPF, DKIM, DMARC and reverse DNS are configured correctly. This is essential to avoid emails landing in spam with Gmail, Outlook and other providers.

On this page