Skip to content
Back to Blog

Infrastructure

Self-Hosted Email with Mailcow: Complete Setup Guide

ZentisLabs Team15 min read

In an era of mass surveillance and data harvesting, self-hosting your email server gives you complete control over your communications. No third-party provider reading your emails for ad targeting. No arbitrary storage limits. No risk of losing access because a provider changed their terms.

Mailcow is the gold standard for self-hosted email. It bundles everything you need: IMAP/SMTP/POP3, a beautiful SOGo webmail interface, anti-spam with Rspamd, anti-virus with ClamAV, calendar and contacts via CalDAV/CardDAV, and automatic SSL certificate management.

Requirements

Before you begin, you need:

  • A VPS with at least 4GB RAM and 2 vCPUs - ZentisLabs Mailcow Starter plan ($84/mo) is ideal
  • A domain name pointing to your server IP
  • Clean IP address - not on any email blacklists
  • Ports 25, 80, 443, 587, 993 open and not blocked by your provider

Step 1: Deploy Your VPS

Sign up at zentislabs.com and deploy a Starter VPS (2 vCPU, 4 GB RAM, 100 GB, $47/mo) in any of our 19 locations, or pick Mailcow as a one-click app on a $84/mo server (4 vCPU, 8 GB RAM) and let the installer handle Steps 1 and 2 for you. We recommend Frankfurt or Amsterdam for European email delivery, or New York/Chicago for US-based operations.

SSH into your server and update the system:

bash
apt update && apt upgrade -y
apt install -y curl git docker.io docker-compose

Step 2: Install Mailcow

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

Enter your mail domain (e.g., mail.yourdomain.com) when prompted. Then edit mailcow.conf to set your timezone and adjust memory limits if needed.

bash
docker-compose pull
docker-compose up -d

Step 3: DNS Configuration

This is the most critical step. Set these DNS records:

text
# A Record
mail.yourdomain.com -> YOUR_SERVER_IP
# MX Record
yourdomain.com -> mail.yourdomain.com (priority 10)
# SPF (TXT)
yourdomain.com -> v=spf1 a mx ip4:YOUR_SERVER_IP ~all
# DKIM (TXT) -- get from Mailcow admin panel
# DMARC (TXT)
_dmarc.yourdomain.com -> v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com

Add these records at your domain registrar or DNS host. On a one-click Mailcow server, the DNS tab of your server page lists every record with your server IP already filled in.

Step 4: Security Hardening

Install fail2ban to protect against brute force attacks, configure UFW firewall to only allow necessary ports, and ensure SSL certificates auto-renew via Let's Encrypt (Mailcow handles this automatically).

bash
apt install -y fail2ban
ufw allow 22,25,80,443,587,993/tcp
ufw enable

Step 5: First Login & Mailbox Setup

Navigate to https://mail.yourdomain.com in your browser. Default credentials are admin/moohoo - change them immediately. Add your domain, create mailboxes, and configure DKIM from the admin panel. Mailcow will automatically handle TLS certificates via Let's Encrypt.

Pro tip: After setup, test your email deliverability at mail-tester.com. A score of 9/10 or higher means your configuration is production-ready. Most issues come from missing DKIM or DMARC records.

Ready to get started?

Try ZentisLabs free - 100MB residential bandwidth included.