Skip to content
Logo
Table of contents
VeryCloud
DocumentationVPS Linux

Install Mailcow: professional self-hosted mail server

Install Mailcow: professional self-hosted mail server

Deploy your own complete mail server with web interface, antispam, antivirus, calendar and webmail. Mailcow bundles Postfix, Dovecot, SOGo, Rspamd, ClamAV and a modern admin panel in a ready-to-use Docker stack.

Category
VPS Linux
Level
Intermediate
Reading time
5 min
Published
May 16, 2026

Introduction

Mailcow: dockerized is the go-to solution to host your own mail server without the complexity of manually configuring Postfix/Dovecot. You get:

  • Unlimited mailboxes across multiple domains
  • SOGo webmail (modern interface)
  • CalDAV calendar and CardDAV address book
  • Rspamd antispam (very effective)
  • ClamAV antivirus
  • Auto-configured DKIM/SPF/DMARC
  • Quotas, aliases, mailing lists

Prerequisites

  • Debian 12 or Ubuntu 22.04+ VPS with minimum 6 GB RAM and 80 GB disk
  • Docker and Docker Compose installed
  • Configured rDNS (mandatory, ask VeryCloud via ticket if not done yet)
  • Ports 25, 80, 110, 143, 443, 465, 587, 993, 995, 4190 open
  • A domain name with DNS control
  • Outbound port 25 not blocked (check with telnet smtp.gmail.com 25)

Step 1: Prepare the system

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git

Make sure the hostname is properly set:

sudo hostnamectl set-hostname mail.your-domain.com

Step 2: Clone Mailcow

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

Step 3: Generate the configuration

sudo ./generate_config.sh

The script asks:

  • Mail server hostname (FQDN): mail.your-domain.com
  • Timezone: Europe/Paris
  • Branch: master

A mailcow.conf file is created. You can edit it to adjust ports if necessary (e.g. if Nginx already runs on 80/443).

Step 4: Start the stack

sudo docker compose pull
sudo docker compose up -d

First launch takes 5-10 minutes (downloading ~3 GB of images).

Check:

sudo docker compose ps

All containers should be Up or healthy.

Step 5: Configure DNS records

This is the critical part. At your registrar (OVH, Gandi, Cloudflare, etc.), add:

Type    Name                 Value
A       mail                 YOUR_VPS_IP
A       autodiscover         YOUR_VPS_IP
A       autoconfig           YOUR_VPS_IP
MX      @                    10 mail.your-domain.com
TXT     @                    "v=spf1 mx -all"
TXT     _dmarc               "v=DMARC1; p=reject; rua=mailto:[email protected]"

The DKIM record is generated from the Mailcow interface in the next step.

Step 6: First admin login

Open:

https://mail.your-domain.com

Default credentials:

  • Username: admin
  • Password: moohoo

Change the password immediately in Access → Edit administrator.

Step 7: Add a domain and a user

Configuration → Mail Setup → Domains → Add domain:

  • Domain: your-domain.com
  • Description: Main domain
  • Aliases: 400 (default)
  • Mailboxes: 10 (as needed)
  • Domain quota: 10240 MB

Validate. Mailcow auto-generates the DKIM key.

Configuration → Mail Setup → Mailboxes → Add mailbox:

  • Username: contact
  • Domain: your-domain.com
  • Full name: Contact
  • Password: choose a strong password
  • Quota: 1024 MB

You now have [email protected].

Step 8: Configure DKIM in DNS

In Configuration → Mail Setup → Configuration → ARC/DKIM keys, copy the displayed DKIM key and add it to your DNS:

Type    Name                         Value
TXT     dkim._domainkey              "v=DKIM1; k=rsa; p=MIGfMA0GC..."

Wait a few minutes for propagation.

Step 9: Test sending and receiving

Log in to SOGo webmail:

https://mail.your-domain.com/SOGo/

Send a test email to your Gmail/Outlook address. The mail should arrive in the inbox (not spam).

Check your score with mail-tester.com:

  1. Send a mail to the random address they give
  2. Click "Then check your score"
  3. Target: 10/10

Step 10: Configure a mail client

On Outlook, Thunderbird or iOS/Android, use the autodiscover settings that configure automatically.

Manual configuration (IMAP/SMTP):

IMAP: mail.your-domain.com    Port 993    SSL/TLS
SMTP: mail.your-domain.com    Port 587    STARTTLS
Username: [email protected]

Troubleshooting

Receives mails but can't send

Outbound port 25 is likely blocked by VeryCloud (standard anti-spam measure). Open a support ticket to request unblocking, justifying your usage.

Mails go to spam

Check:

dig +short TXT your-domain.com
dig +short TXT _dmarc.your-domain.com
dig +short TXT dkim._domainkey.your-domain.com

All three must respond. Otherwise, DNS records are not properly configured.

Check rDNS:

dig +short -x YOUR_VPS_IP

Should return mail.your-domain.com. If not, configure it in the VeryCloud customer area or ask support.

Unhealthy container

sudo docker compose logs CONTAINER_NAME --tail 100

Most often: lack of RAM. Mailcow requires 6 GB minimum.

Useful commands

# Container status
sudo docker compose ps

# Service logs
sudo docker compose logs -f postfix-mailcow
sudo docker compose logs -f rspamd-mailcow

# Update Mailcow
cd /opt/mailcow-dockerized
sudo ./update.sh

# Backup
sudo ./helper-scripts/backup_and_restore.sh backup all

# Restore
sudo ./helper-scripts/backup_and_restore.sh restore

# Restart full stack
sudo docker compose down && sudo docker compose up -d

Conclusion

You now have a professional self-hosted mail server on your VeryCloud VPS, with all the features of Gmail/Office 365 and no recurring per-user fees. Key points to remember:

  • Monitor blacklists (mxtoolbox.com)
  • Backup regularly (emails are precious)
  • Update Mailcow monthly (./update.sh)
  • A "fresh" IP takes 1-2 weeks to warm up before stopping landing in spam

Resources

Join our Discord community server

For any questions, suggestions, or just to chat with the community, join us on Discord!

900+Members