DU
Digital Universe
Back to Blog
Email2025-02-1511 min read

Setting Up Mailcow on Hetzner: Your Own Email Server

Run your own email server with Mailcow on Hetzner. Covers why self-hosted email matters, what Mailcow includes, and the key configuration decisions.

Why Self-Host Email?

Google Workspace costs $7.20/user/month. Microsoft 365 starts at $6/user/month. For a team of 10, that's $72-86/month just for email.

Mailcow on a Hetzner VPS costs $0 additional — it runs alongside your other services on the same server.

But cost isn't the only reason. Self-hosted email gives you:

  • Complete data ownership — no third party reading your email
  • Unlimited aliases and domains
  • Custom filtering and routing rules
  • No vendor lock-in

What Is Mailcow?

Mailcow is a Docker-based email server suite that includes:

  • Postfix — SMTP server (sending/receiving)
  • Dovecot — IMAP/POP3 server (mailbox access)
  • SOGo — Webmail client with calendar and contacts
  • Rspamd — Spam filtering
  • ClamAV — Antivirus scanning
  • Automatic SSL via Let's Encrypt
  • Admin panel with user and domain management

Everything runs in Docker containers, managed through a clean web interface.

Prerequisites

Before installing Mailcow, you need:

1. A Hetzner VPS with at least 8GB RAM (CPX42 recommended)

2. Docker and Docker Compose installed

3. A domain name with DNS access

4. A clean IP — Check if your server's IP is on any blacklists

DNS Requirements

Email requires specific DNS records. At minimum:

RecordTypeValue
mail.yourdomain.comAYour server IP
yourdomain.comMXmail.yourdomain.com (priority 10)
yourdomain.comTXT (SPF)v=spf1 ip4:YOUR_IP ~all
yourdomain.comTXT (DMARC)v=DMARC1; p=quarantine; ...
dkim._domainkey.yourdomain.comTXT(generated by Mailcow)

The PTR Record

This is the one people forget. A PTR (reverse DNS) record maps your IP back to your mail hostname. Without it, many mail servers will reject your email.

In the Hetzner Cloud Console, go to your server's networking tab and set the reverse DNS to mail.yourdomain.com.

Installation Overview

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

The config generator asks for your mail hostname and timezone. After that:

docker compose up -d

Mailcow will pull and start ~15 containers. The admin interface will be available at https://mail.yourdomain.com.

Key Configuration Decisions

1. Hostname: Use mail.yourdomain.com, not just yourdomain.com

2. Skip ClamAV if you have less than 4GB RAM dedicated to Mailcow

3. Solr search is optional and memory-hungry — disable for smaller servers

4. Backup strategy: Mailcow includes a backup script, use it

The Biggest Challenge

If you're running Mailcow alongside Coolify on the same server, you'll face a port conflict. Both services need ports 80 and 443 for their web interfaces and SSL.

This is the single most common failure point in dual-stack setups, and the solution requires coordinating Coolify's Traefik proxy with Mailcow's Nginx.

Our complete guide documents the exact configuration changes we use in production to resolve this.

Is Self-Hosted Email Worth It?

Yes, if:

  • You value data ownership
  • You have multiple domains/users
  • You're already running a VPS
  • You're willing to maintain it

No, if:

  • You need 99.999% uptime guarantees
  • You don't want to manage DNS records
  • Email deliverability debugging sounds painful
  • You just need email for 1-2 people (use Fastmail instead)

Self-hosted email is one of the most rewarding self-hosting projects, but it requires ongoing attention to maintain deliverability.

#mailcow#email#self-hosted#hetzner#smtp

Want the Complete Setup Guide?

This blog post covers the basics. Our premium guide includes step-by-step commands, exact configurations, and the solutions to every gotcha we encountered.