VPSGauge

How to Self Host a Mail Server on a VPS: mailcow, DNS and the Honest Catch

Updated Nov 14, 2026 · by Kane · how we check

Part of Self-hosting, our guide to this topic

Live data the 3 prices on this page come from 3 providers' own sites, read daily. Last read Dec 4, 2026 · last price change Oct 11, 2026 (Hetzner CX33 $10.49 → $10.59).

Short answer

To self host a mail server, rent a VPS from a provider that lets you send on port 25, point a domain at it, and run an all-in-one stack such as mailcow, which bundles Postfix, Dovecot and Rspamd behind Docker. Then publish the DNS records other servers check — MX, SPF, DKIM and DMARC — and set reverse DNS. The honest catch is deliverability: a fresh server IP has no sending reputation, so your first mail can land in spam until you warm the address up or relay outbound mail through a trusted sender. Plan an afternoon and a server with at least 6 GB of RAM.

Time
2–3 hrs
Steps
4
Works on
Ubuntu
24.04 LTS
On this page
  1. Self-hosted email: is it worth it?
  2. What you need before you start
  3. DNS records your mail server needs
  4. The port 25 problem
  5. IP reputation: why your first mail lands in spam
  6. How to self host a mail server with mailcow
    1. 1Check port 25 and set reverse DNS
    2. 2Point DNS at the server
    3. 3Install Docker and mailcow
    4. 4Log in, add DKIM and DMARC, and test
  7. Key takeaways
  8. A VPS for this guide
  9. Don’t send bulk mail from it
  10. What it costs to run
  11. Questions

This guide has no affiliate links in the steps.

A mail server in the middle of signed, locked and checked messages, drawn in ink and orange on paper white.

Self-hosted email: is it worth it?

For most people, no. The people who actually run it say the hard part is not the setup — it is getting mail into the inbox. A March 2026 r/selfhosted thread (417 upvotes) lists the common stacks — Postfix/Dovecot/Rspamd, mailcow and Stalwart — and the workaround many land on: relay outbound mail through Amazon SES or SMTP2GO, because a new IP has no reputation. One commenter ran a full stack on a cheap RackNerd yearly plan and said the first weeks went straight to spam. A September 2026 r/webdev thread shows the same failure at the other end: a 25-year-old domain moved to a new VPS, and Gmail rejected 241 of 250 forwarded messages as “very low reputation”.

So the honest answer: self-host for control, privacy or to learn how mail works — not to save money. A hosted mailbox costs a few dollars a month and someone else keeps the IP warm.

What you need before you start

  • A domain you control, where you can add DNS records.
  • A VPS whose provider will let you send on port 25, or a plan to relay outbound mail instead. More on both below.
  • At least 6 GB of RAM, KVM virtualization. mailcow’s own minimum is 6 GiB of RAM plus 1 GiB of swap, 20 GiB of disk before any mail, and a full virtual machine — it does not support OpenVZ, Virtuozzo or LXC containers. mailcow suggests 8 GiB for about 5 to 10 users (mailcow system requirements, read Nov 14, 2026).
  • Ubuntu 24.04 hardened first. A mail server holds every account you send from, so work through the new VPS setup checklist before you install anything. New to servers? Start with what a VPS actually is.
  • An afternoon. The install is quick; DNS changes and reputation take longer.

mailcow documentation, system requirements table: the RAM row reads Minimum 6 GiB + 1 GiB swap (default config), between CPU 1 GHz and Disk 20 GiB (without emails). mailcow’s floor is 6 GiB of RAM plus 1 GiB of swap. Source: docs.mailcow.email, captured Nov 20, 2026.

DNS records your mail server needs

Other servers decide whether to accept your mail from five records. This is the part people skip, and the part that decides inbox vs spam.

  • MX — where mail addressed to your domain should be delivered (your server’s hostname).
  • SPF — which servers are allowed to send as your domain.
  • DKIM — a signature that proves the message was not altered in transit.
  • DMARC — your policy for what to do when SPF or DKIM fails.
  • PTR (reverse DNS) — the hostname that maps back to your IP. mailcow says it must match your mail server’s full hostname.

The r/webdev thread above is a textbook case: the commenters’ first fix was SPF, DKIM and DMARC. The exact values to enter are in steps 1, 2 and 4 below.

YOUR DOMAIN RECEIVING SERVER MX where your mail is delivered SPF who may send as you DKIM signs each message DMARC policy when checks fail PTR hostname for your IP what decides inbox vs spam checks every message: SPF matches the sending server DKIM signature is valid DMARC policy is satisfied PTR points back to the hostname then it weighs your IP reputation, which the records can not fix.
YOUR DOMAIN MX where your mail is delivered SPF who may send as you DKIM signs each message DMARC policy when checks fail PTR hostname for your IP what decides inbox vs spam RECEIVING SERVER checks every message: SPF matches the sending server DKIM signature is valid DMARC policy is satisfied PTR points back to the hostname then it weighs your IP reputation.

The port 25 problem

Port 25 is the port servers use to hand mail to each other. Many VPS providers block outbound port 25 by default to stop spam from their networks, and a 2024 Hacker News thread says new accounts usually have to open a support ticket to get it unblocked. Here is what the providers we track say in their own docs (checked Nov 14, 2026):

  • netcup — new servers come with a default firewall policy that blocks sending mail; you delete that policy yourself in the Server Control Panel, no ticket needed (netcup firewall docs).
  • OVHcloud — port 25 is not blocked by default on its VPS servers. The exception is Local Zone VPS, where SMTP ports can’t be opened at all (OVHcloud VPS FAQ).
  • Hetzner — ports 25 and 465 are blocked on all cloud servers. Once you have been a customer for a month and paid your first invoice, you can file a limit request to unblock them for a valid use case (Hetzner Cloud FAQ).
  • Vultr — port 25 is blocked; you can ask for it to be removed with a support ticket (Vultr blocked ports).
  • Akamai / Linode — ports 25, 465 and 587 are restricted on some accounts created after November 5, 2019; support reviews unblock requests that include your use case, how you’ll prevent unwanted mail, and your sending domains (Akamai: send email).
  • Interserver — outbound port 25 is blocked on all VPS by default. Staff open it after a manual review, once the server has been active a month with no unpaid invoices and has a hostname and valid reverse DNS (Interserver SMTP support).
  • DigitalOcean — ports 25, 465 and 587 are blocked on all Droplets, and the docs point you to a third-party email service rather than an unblock request (DigitalOcean: why is SMTP blocked).

Hetzner Docs, Cloud server FAQ: Hetzner blocks ports 25 and 465 by default on all cloud servers, and once you have been a customer for a month and paid your first invoice you can create a limit request to unblock them. Hetzner opens port 25 only after a month and a paid invoice, case by case. Source: docs.hetzner.com, captured Nov 20, 2026.

For the other providers we track we did not find an official statement. Ask support before you buy — especially before paying for a year up front — or plan to relay.

DigitalOcean docs, why is SMTP blocked: SMTP ports 25, 465 and 587 are blocked on all Droplets by default, including traffic through a Reserved IP; the next paragraph recommends against running your own mail server. DigitalOcean blocks all three SMTP ports on every Droplet. Source: docs.digitalocean.com, captured Nov 20, 2026.

YOUR MAIL SERVER RECEIVING SERVER mail.example.com mailcow: Postfix, Dovecot, Rspamd PORT 25 usually blocked; rules vary by host big inbox providers checks SPF, DKIM, DMARC, PTR then your IP reputation the gate is the provider's, not yours
YOUR MAIL SERVER mail.example.com mailcow: Postfix, Dovecot, Rspamd PORT 25 often blocked by default RECEIVING SERVER big inbox providers checks SPF, DKIM, DMARC, PTR the gate is the provider's, not yours

IP reputation: why your first mail lands in spam

Even with the records right, a brand-new IP starts from zero. Receiving servers treat a server with no sending history as suspicious, and a May 2026 Hacker News thread warns that many VPS providers’ IP ranges are already “dirty” from past abuse, which makes delivery hard no matter what you do. The reputation problem leaks sideways too: one person blocked every OVH Canada IP range after attacks, which hits the normal users on those ranges as well. These are reports from other operators, not our tests.

The two ways out: warm the IP up slowly over weeks, or relay outbound mail through a trusted sender like SMTP2GO or Amazon SES and keep your own server for receiving. The r/selfhosted thread recommends the relay as the practical default.

DIRECT · YOUR OWN IP YOUR SERVER sends outbound YOUR NEW IP no sending history SPAM FOLDER for the first weeks RELAY · TRUSTED SENDER YOUR SERVER sends to the relay RELAY SERVICE established reputation INBOX much sooner relaying skips the reputation warm-up, at the cost of a third party seeing your outbound mail
DIRECT · YOUR OWN IP YOUR SERVER sends outbound YOUR NEW IP no sending history SPAM FOLDER for the first weeks RELAY · TRUSTED SENDER YOUR SERVER sends to the relay RELAY SERVICE established reputation INBOX much sooner relaying skips the warm-up; a third party sees outbound mail

How to self host a mail server with mailcow

mailcow is the most common all-in-one choice — the r/selfhosted thread names it alongside Postfix/Dovecot/Rspamd and Stalwart. It bundles Postfix (sending and receiving), Dovecot (IMAP/POP3 mailboxes), Rspamd (spam filtering), the SOGo webmail and a web admin behind Docker Compose, so you install one stack instead of wiring six services together by hand. The commands below follow mailcow’s install guide (read Nov 14, 2026); the examples use mail.example.com as the hostname and 203.0.113.10 as the server’s IP — swap in yours.

1

Check port 25 and set reverse DNS

Before installing anything, make sure the provider lets you send on port 25 (see the list above) and remove the block or open the ticket now, since some providers take days or need a month of account history. Then set the server’s reverse DNS (PTR) to your mail hostname, mail.example.com, in the provider’s control panel — it is set where you rent the IP, not at your domain registrar. If you use IPv6, set it for the IPv6 address too (mailcow DNS setup).

mailcow documentation, reverse DNS section: make sure the PTR record of your IP address matches the FQDN of your mailcow host; it is usually set at the provider you leased the IP from, for IPv4 and IPv6. The PTR record must match your mail hostname, and it is set at the server provider. Source: docs.mailcow.email, captured Nov 20, 2026.

If it fails: The provider’s panel won’t let you change reverse DNS. Ask support; without a matching PTR, many receiving servers will distrust your mail.

2

Point DNS at the server

At your domain’s DNS host, add the records mailcow lists as its minimal setup, plus SPF:

Name Type Value
mail A 203.0.113.10
autodiscover CNAME mail.example.com.
autoconfig CNAME mail.example.com.
@ MX (priority 10) mail.example.com.
@ TXT (SPF) v=spf1 mx a -all

The mail A record only goes on the domain mailcow runs on; any extra domains you host later need just the MX. The SPF value is mailcow’s example: it lets your MX and A hosts send for the domain and tells receivers to reject everything else (mailcow DNS setup). DKIM and DMARC come in step 4, once mailcow has generated your key.

mailcow documentation, DNS setup: the example zone file snippet for SPF, a TXT record on @ with the value v=spf1 mx a -all. The SPF value in step 2 is mailcow’s own example. Source: docs.mailcow.email, captured Nov 20, 2026.

If it fails: You already send mail for this domain through another service. Add that service to the SPF record before you publish it, or its mail will start failing.

3

Install Docker and mailcow

SSH into the server (how to SSH into a VPS) and switch to a root shell — mailcow’s guide runs every step as root:

serversudo -i

Install the tools mailcow needs, then Docker from Docker’s own script (mailcow asks for the latest Docker Engine, not the distro’s package):

serverapt update
apt install -y git openssl curl gawk coreutils grep jq
curl -sSL https://get.docker.com/ | CHANNEL=stable sh
systemctl enable --now docker
apt install docker-compose-plugin

Want to know what that script sets up? Our Docker on Ubuntu guide walks through it. Now download mailcow and generate its config:

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

The script asks for your mail hostname — enter the full name, mail.example.com. Then pull the images and start the stack:

serverdocker compose pull
docker compose up -d

If it fails: Something else on the server already uses port 25, 80 or 443. mailcow needs 25, 465, 587, 143, 993, 110, 995, 4190, 80 and 443; check with ss -tlpn | grep -E -w '25|80|110|143|443|465|587|993|995|4190' and stop whatever answers. A firewall note too: mailcow says UFW and firewalld cause problems with it, and that ordinary INPUT rules don’t restrict its Docker-published ports, so don’t rely on UFW to lock it down (mailcow system requirements).

mailcow documentation, danger box: there are several problems with running mailcow on a firewalld/ufw enabled system; INPUT rules have no effect on restricting access to mailcow, use the FORWARD chain or DOCKER-USER chain instead. mailcow warns that UFW and INPUT rules don’t restrict its Docker ports. Source: docs.mailcow.email, captured Nov 20, 2026.

4

Log in, add DKIM and DMARC, and test

Open https://mail.example.com/admin and log in with mailcow’s default credentials — user admin, password moohoo — then change the password straight away. Add your domain and a mailbox.

mailcow install guide, last step: you can now access https://${MAILCOW_HOSTNAME}/admin using the default credentials admin and the password moohoo. The default admin password is public, so change it the moment you log in. Source: docs.mailcow.email, captured Nov 20, 2026.

In the admin UI, create a DKIM key for the domain and copy the TXT record it shows into your DNS as dkim._domainkey. Then add a DMARC record; mailcow’s example is:

Name Type Value
dkim._domainkey TXT v=DKIM1; k=rsa; t=s; s=email; p=... (from mailcow)
_dmarc TXT v=DMARC1; p=reject; rua=mailto:mailauth-reports@example.com

p=reject tells receivers to refuse mail that fails the checks, and rua is where they send reports.

Finally, send a message from your new mailbox to an address you have at a big mail provider, open it there and view the original headers. You want SPF, DKIM and DMARC all to show pass.

If it fails: The message lands in spam even though all three pass. That is the reputation problem from above, not a setup error — warm the IP up slowly, or relay outbound mail.

Key takeaways

  1. To self host a mail server you need a domain, a VPS with outbound port 25 (or a relay), and an all-in-one stack such as mailcow.
  2. mailcow needs at least 6 GB of RAM plus swap on a KVM server; 8 GB is comfortable for a few users.
  3. MX, SPF, DKIM, DMARC and PTR are the five records that decide inbox vs spam.
  4. A fresh IP has no reputation; the first weeks go to spam unless you warm up or relay through SMTP2GO or SES.
  5. Port 25 rules differ a lot: netcup lets you open it yourself, OVHcloud VPS leaves it open, Hetzner and Interserver need a month of history, DigitalOcean keeps it shut.
  6. Bulk and marketing mail is against most providers’ terms — this is not the tool for newsletters.

A VPS for this guide

Everything above runs on a VPS with 6 GB of RAM or more. The cheapest 6 GB+ plan at each provider whose prices we read every day, IPv4 included:

Plan · providervCPU · RAM · diskYou payVisit
Cloud VPS 4
Contabo · Asia (India) +8
4 vCPU·8 GB·100 GB$6.60/mo
KVM VPS Special 6 GB
RackNerd · New York +3
6 vCPU·6 GB·100 GB$7.50/mo
VPS Lite 2 G12.5s
netcup · Nuremberg +2
4 vCPU·8 GB·160 GB$8.64/mo
NVMe 8 GB
HostHatch · Amsterdam +15
2 vCPU·8 GB·35 GB$9.00/mo
3 slices
InterServer · New York +2
2 vCPU·6 GB·120 GB$9.00/mo

Prices read Dec 4, 2026. gets that provider's deals on Telegram. Compare every 6 GB plan →

Don’t send bulk mail from it

Say this plainly: marketing or bulk mail is against most providers’ terms, and it is the fastest way to get your IP blacklisted for everyone. Interserver, for one, refuses mail-only servers and IP rotation outright. If sending newsletters is the goal, a mail server on a VPS is the wrong tool — use a service built for it. If you want a few honest mailboxes for you and your projects, this is the right tool, used gently.

What it costs to run

mailcow wants 6 GB of RAM at minimum and 8 GB for a handful of users. Three 8 GB plans from our data, all read daily, from providers whose port 25 rules are documented above:

  • netcup VPS Lite 2 — 4 vCPU, 8 GB, 160 GB at $8.64/month. The cheapest of the three, and port 25 opens from your own control panel. Catch: a 3-month minimum term, ID verification after your first order, and picking a specific data center costs extra.
  • OVHcloud VPS-2 — 4 vCPU, 8 GB, 75 GB NVMe at $10.00/month, billed monthly. Port 25 isn’t blocked by default. Catch: no refunds by default, and OVHcloud may ask for ID documents.
  • Hetzner CX33 — 4 vCPU, 8 GB, 80 GB NVMe at $10.59/month, billed monthly. Catch: port 25 stays shut until you’ve been a customer for a month and paid an invoice, so start by relaying.

The “A VPS for this guide” table on this page lists the cheapest 6 GB+ plan at each provider whose prices we read ourselves — check the port 25 list before you pick one. To compare more, compare every plan by real monthly cost.

Questions

Is it worth self hosting your own email?

Only if you want control, privacy or the learning — not to save money. Getting a new IP to reach inboxes reliably is slow work, and a hosted mailbox is a few dollars a month.

Why does my self-hosted email go to spam?

Almost always reputation: a new server IP has no sending history. Missing SPF, DKIM or DMARC records, a wrong PTR record, or a “dirty” IP range make it worse.

What is port 25 and why is it blocked?

It is the port mail servers use to send between each other. Many providers block it by default to stop spam. Some let you open it yourself (netcup), some after a ticket or a month of history (Vultr, Hetzner, Interserver), OVHcloud VPS leaves it open, and DigitalOcean keeps it closed.

How much RAM does mailcow need?

mailcow’s minimum is 6 GiB of RAM plus 1 GiB of swap, with 8 GiB recommended for about 5 to 10 users. Its antivirus and full-text search are the hungriest parts and can be switched off.

What is the best mail server software for a VPS?

mailcow is the most common all-in-one: Postfix, Dovecot, Rspamd and a web UI behind Docker. Postfix/Dovecot/Rspamd by hand and Stalwart are the other stacks people run.

Can I self host email without port 25?

You can’t receive mail from other servers without inbound port 25, but you can skip sending on it: receive mail yourself and relay outbound mail through a service like SMTP2GO or Amazon SES. You skip the unblock fight and start with an established reputation.

How we checked: We did not run a mail server for this article. The mailcow requirements, commands and DNS records come from mailcow’s own documentation, and the port 25 rules from each provider’s docs, all read on November 14, 2026. Prices come from our daily reads of provider pages; the other provider terms (minimum term, refunds, ID checks) come from our checked notes on each provider. The deliverability reports come from the linked, dated Reddit and Hacker News threads. How we check.

Keep reading