
Email hosting looks simple until you run it yourself. The hard part isn’t the inbox UI. It’s consistent delivery, protecting your domain’s reputation, and blocking spam without blocking real people.
If you want to deploy Mailcow on a VPS instead of paying for Google Workspace-style hosting, Mailcow is a practical open-source choice in 2026. It’s an opinionated, containerized stack built for daily operations.
You get Postfix + Dovecot, spam and virus filtering, an admin UI, and the DNS pieces (DKIM, SPF, DMARC) that decide whether your mail lands in the Inbox, Promotions, or nowhere at all.
Mailcow, in plain terms: who it’s for and what it replaces
Mailcow (Mailcow: Dockerized) is a self-hosted email suite. You run it on your own infrastructure. You control domains, users, storage, and security policies.
It’s a good fit if you:
- Need mailboxes for a team but don’t want per-user SaaS pricing.
- Handle sensitive client data and want predictable data location and retention.
- Already operate a VPS or dedicated server and you’re comfortable owning updates and backups.
- Want modern features without building a mail stack from scratch.
What it replaces depends on where you’re starting:
- Google Workspace / Microsoft 365: You swap vendor-managed infrastructure and bundled office apps for tighter control and better cost predictability as mailbox counts grow.
- Hosted mailbox providers: You gain control over deliverability knobs, logging, and storage. You also take on the operational responsibility.
- DIY Postfix/Dovecot builds: You get an integrated admin experience and a deployment model the project supports (Docker Compose) instead of a hand-rolled stack.
License note: Mailcow is an open-source project. Individual components in the stack (Postfix, Dovecot, Rspamd, etc.) use their own licenses.
Review the upstream repository documentation before production rollout. This matters even more if you have compliance requirements.
What you get (and what you still need to bring)
Mailcow covers the pieces most teams don’t want to stitch together themselves:
- SMTP + IMAP/POP: Postfix and Dovecot, with sensible defaults.
- Anti-spam + filtering: Typically Rspamd-based filtering with policy controls.
- Admin UI: Domain, mailbox, alias management, quotas, and logs.
- Webmail: A web interface for users (varies by Mailcow configuration).
- TLS and modern ciphers: Designed to keep traffic encrypted in transit.
You still need to bring the fundamentals:
- A VPS or dedicated server with a clean IP reputation (or a plan to earn it).
- Correct DNS (A/AAAA, MX, PTR/rDNS, SPF, DKIM, DMARC, and optional MTA-STS/TLS-RPT).
- Backups that you’ve actually restored at least once.
- Routine updates and monitoring so you know when mail stops flowing.
Resource planning before you deploy Mailcow on a VPS
Email is I/O-heavy and storage-driven. CPU spikes usually come from spam and AV scanning.
In practice, disk growth causes more outages than “not enough cores.”
- Small team (5–25 mailboxes): 2 vCPU, 4 GB RAM, 60–120 GB NVMe storage.
- Medium team (25–150 mailboxes): 4 vCPU, 8–16 GB RAM, 200–500 GB NVMe storage.
- Heavy inbound spam pressure or large attachments: plan more CPU and faster disk, or separate scanning services if your design allows it.
Plan for growth. Mailboxes rarely shrink. Attachment-heavy teams also expand faster than you expect.
If you’re migrating from an existing provider, measure current usage per domain. Then leave headroom.
A VPS is usually the right starting point. If you need predictable IOPS, very large storage, or you’re hosting email for many client domains, a dedicated server can be simpler long term.
HostMyCode offers both paths. Start with a HostMyCode VPS for a single organization. Step up to managed or dedicated resources as mail volume grows.
Operational reality check: IP reputation, rDNS, and the “new server” penalty
Deliverability isn’t just “port 25 open.” Receiving systems score your mail using DNS alignment, authentication, sending history, and content signals.
Before you touch Docker Compose, confirm these basics:
- rDNS (PTR): Your server IP should reverse-resolve to a hostname that forward-resolves back to the same IP.
- HELO/EHLO name: Should match your mail hostname (not “localhost”).
- New IP warming: Expect stricter filtering at first. Start with low volume and ramp up.
If you can’t set rDNS for your VPS IP, stop and fix that first. Otherwise you’ll spend your time chasing avoidable spam-folder placement and deferrals.
Quick comparison: Mailcow vs hosted email suites
Hosted suites win on low maintenance, global delivery tuning, and bundled collaboration apps. Mailcow wins when you want control and predictable costs once mailbox counts rise.
- Admin control: Mailcow gives you direct visibility into logs and policies. Hosted suites hide most of that.
- Data location: With Mailcow, you choose the region and retention model.
- Cost model: VPS cost scales with resources, not per user. That’s useful for teams with shared mailboxes or lots of aliases.
- Operations burden: You own patching, backups, and incident response. Hosted providers own it.
If you want the control without living in server dashboards, consider a managed VPS hosting approach. The provider handles server maintenance while you keep app-level control.
Deployment model: Docker Compose, stable storage, and sensible paths
Mailcow is typically deployed with Docker Compose. That’s not just convenience. It’s the supported model for running the full multi-service stack.
A clean layout on Ubuntu or Debian looks like this:
/opt/mailcow-dockerized/for the stack/var/lib/docker/on fast local disk (NVMe if possible)- Backups written to
/var/backups/mailcow/and copied off-host
Ubuntu Server LTS and Debian Stable both work well. Keep the host minimal.
Avoid piling unrelated web apps onto the same machine. If you do, be disciplined about ports and security boundaries.
How the install actually goes (high-level, not hand-wavy)
This is a blog post, not a command-by-command walkthrough. Here’s what the process looks like in practice:
- Provision the server: set hostname (for example
mail.example.com), configure time sync, update packages. - Install Docker + Compose plugin: use your distro packages where possible, keep Docker updated.
- Clone Mailcow and generate config: Mailcow provides a configuration generator that asks for mail domain, timezone, and other basics.
- Bring the stack up:
docker compose up -dafter config is generated. - Lock down access: expose only what must be exposed, restrict admin UI, set strong passwords, enable MFA if available.
If you already run other apps on the same VPS, plan port usage up front. Email relies on standard ports, and clients expect them to work.
Ports and firewall rules you should expect
At minimum, you’ll typically open:
- 25/tcp (SMTP) inbound for server-to-server mail
- 465/tcp (SMTPS) for legacy clients (sometimes optional)
- 587/tcp (Submission) for authenticated sending
- 143/tcp (IMAP) often redirected to TLS or closed
- 993/tcp (IMAPS) for mail clients
- 80/tcp and 443/tcp for web UI, ACME challenges, and admin (prefer 443 only, with 80 for redirect/ACME)
Then reduce the admin attack surface. If you can, restrict admin UI access to a VPN or a small IP allowlist.
If you want to keep admin private without opening extra firewall access, the approach in Set Up Cloudflare Tunnel on a VPS for Private Admin can be adapted for mail admin portals (mail traffic still needs direct SMTP/IMAP).
Reverse proxy + HTTPS: keep it boring
Mailcow can manage TLS inside the stack, and many operators leave it that way. If you prefer a dedicated reverse proxy (Caddy or Nginx), use it for the web UI only.
Don’t proxy SMTP/IMAP unless you’re confident about STARTTLS behavior and SNI edge cases.
A practical pattern on a single VPS is:
- Mail protocols (SMTP/IMAP) terminate TLS within Mailcow’s containers.
- Web admin and webmail sit behind a reverse proxy that handles HTTPS and security headers.
If you like Caddy’s automatic certificate management, the workflow in Set Up Let’s Encrypt With Caddy for a VPS Site is the same idea: DNS points to the VPS, Caddy answers on 80/443, and it keeps certificates renewed.
Whichever path you choose, confirm the certificate presented for your mail hostname matches what clients use (mail.example.com). A name mismatch causes setup failures and support tickets.
DNS setup: the checklist that decides deliverability
DNS is where most self-hosted mail projects stumble. Get it right before you migrate users or change MX.
- A/AAAA:
mail.example.com→ your server IP(s) - MX:
example.com→mail.example.comwith a sensible priority (often 10) - PTR (rDNS): your server IP →
mail.example.com(set at the hosting provider) - SPF: authorize your server to send for the domain
- DKIM: publish the DKIM public key Mailcow generates
- DMARC: start with monitoring policy, then tighten once you’ve validated alignment
A conservative DMARC starting point is p=none with aggregate reports.
Move to quarantine, then reject once you’ve confirmed every legitimate sender is aligned and authenticated.
If you’re managing registration and DNS, keeping it centralized reduces mistakes during a cutover.
HostMyCode domain + DNS management at domains and DNS at HostMyCode makes it easier to keep records consistent while you migrate.
Storage, retention, and mailbox quotas that prevent outages
Mail servers don’t fail politely when the disk fills up. You get deferrals, broken indexes, and users who can’t send.
Set these limits early:
- Mailbox quotas: prevent one mailbox from consuming the whole disk.
- Attachment limits: cap what you can scan and store without pain.
- Retention policy: decide how long you keep mail for legal and operational reasons.
Then monitor free space with alerts. Relying on “we’ll notice” is how mail outages happen on weekends.
Backups: what to capture, where to store it, and how to test restores
For Mailcow, you typically back up both persistent data (volumes) and configuration. A usable restore brings back:
- Mailboxes and folders
- Domain and user configuration
- DKIM keys and TLS material (depending on how you manage certificates)
Backup rules that hold up in production:
- Back up locally, then copy off-host: use a second storage target (object storage, another VPS, or a backup server). Local-only backups don’t count.
- Encrypt off-host backups: email content is sensitive data.
- Test restores quarterly: do a real restore into a staging VM, not a checkbox exercise.
If your Mailcow stack uses a database internally (common in these suites), treat it like any other production DB.
Do consistent dumps, set retention, and run periodic restore tests.
The discipline described in Set Up Automatic MySQL Backups With Tested Restores maps well to mail stacks too, even if your specific database engine differs.
Updating safely: minimize downtime and avoid “surprise migrations”
Email updates are less forgiving than updating a blog. A broken web UI is annoying. Broken SMTP is an incident.
Use a repeatable routine:
- Read the release notes: watch for breaking changes and database migrations.
- Snapshot first: take a VPS snapshot or filesystem snapshot right before updating.
- Update during a quiet window: avoid peak sending hours for your region.
- Verify after update: send/receive tests, check queue length, confirm IMAP login, verify TLS validity.
On Ubuntu/Debian, keep the host OS patched too. Kernel and OpenSSL updates matter on a mail server.
Monitoring: the signals that catch email failure early
Mail rarely fails all at once. It usually slides downhill.
You might see queue growth, rising spam scores, or a DNS change that breaks alignment. Certificate renewal can also fail quietly.
At a minimum, monitor:
- Queue depth: sustained growth is a red flag.
- Disk usage: alert before you hit 80%.
- Memory pressure: OOM kills in scanning containers cause confusing partial failures.
- Blacklists: periodic checks for your sending IP and domain.
- TLS expiry: verify renewals ahead of time.
For dashboards, a lightweight metrics setup is often enough. If you already run Grafana, reuse it.
This HostMyCode guide on deploying Grafana with Docker, TLS, and backups is a solid template for getting graphs and alerts in place without turning monitoring into a second full-time job.
Migration notes: moving mailboxes without burning your MX records
The least painful migrations are staged:
- Lower DNS TTL for MX and related records 24–48 hours before the cutover.
- Create mailboxes and aliases in Mailcow first, then migrate historical mail.
- Cut over MX during a quiet period.
- Keep the old provider alive briefly so stragglers and cached resolvers don’t drop mail.
Budget time for user support. SMTP settings, app passwords, and mobile profiles always take longer than expected.
Write down the exact server names, ports, and security options users should enter. Reuse that doc for every ticket.
Security basics that matter specifically for mail servers
Mail servers get hammered nonstop. Usually it’s not targeted. It’s just the internet doing its thing.
Treat baseline hardening as part of the install:
- SSH locked down: key-based auth, no root login, limited IPs if possible.
- Fail2ban or equivalent: protect SSH and any exposed auth endpoints.
- Separate admin access: VPN, allowlist, or tunnel for the admin UI.
- Outbound policy: alerts on unusual send volume to catch compromised accounts.
Also watch for “helpful” DNS edits. Someone adds a third-party sending service, SPF stops aligning, and then DMARC fails.
Keep a simple DNS change log so you can unwind mistakes quickly.
Where Mailcow fits in a hosting stack at HostMyCode
Mailcow is infrastructure, not a hobby container. You need stable storage and reliable networking. You also need a provider that supports proper rDNS/PTR.
Your provider also shouldn’t block essential mail ports by default.
If you want predictable costs and gradual scaling, start with a VPS. Move up once you have real data on mailbox growth and scanning load.
If you already know you’ll host multiple domains, need large NVMe storage, or expect heavy inbound filtering, consider stepping up earlier.
Summary: is Mailcow the right move for your team?
If your goal is to stop paying per-user mailbox fees and you’re comfortable operating a Linux server, Mailcow is a sensible option. It bundles the unglamorous but critical parts—transport, mailbox access, auth, filtering—and adds a management layer that feels cohesive.
Reliability comes from basics done well: accurate DNS, tested backups, scheduled updates, and monitoring with alerts. Email doesn’t need fancy architecture. It needs consistent operations.
If you’re ready to deploy Mailcow on a VPS, choose a plan with enough RAM for scanning and enough disk for the next 12–24 months. A HostMyCode VPS is a solid starting point. If you’d rather not worry about host patching and baseline server upkeep, managed VPS hosting can take that work off your plate.
If you’re replacing Google Workspace-style mail with your own stack, run Mailcow on infrastructure that supports clean networking and consistent uptime. Start with a HostMyCode VPS, and switch to managed VPS hosting if you want OS patching and baseline server maintenance handled for you.
FAQ
Do I need a dedicated server, or is a VPS enough for Mailcow?
A VPS is enough for most small and mid-sized teams. Go dedicated when you need large storage, very high IOPS, or you’re hosting mail for many domains with heavy spam scanning.
What DNS records are non-negotiable for deliverability?
PTR/rDNS, MX, SPF, DKIM, and DMARC. If PTR doesn’t match your mail hostname, you’ll see more deferrals and spam folder placement.
Can I put Mailcow behind a reverse proxy like Nginx or Caddy?
Yes for the web UI and webmail. Be cautious proxying SMTP/IMAP unless you understand STARTTLS behavior and port expectations. Most operators terminate mail-protocol TLS within Mailcow itself.
How do I back up Mailcow correctly?
Back up persistent volumes plus configuration, copy backups off-host, and test a restore into a staging environment. If the restore isn’t tested, it’s a hope—not a backup.
What’s the biggest mistake teams make after migrating from Workspace?
They cut over MX before validating DNS authentication and client settings. Stage the migration, lower TTLs, test sending/receiving, then cut over during a quiet window.