Home
Web Hosting
Domains FAQ
Resources
About Contact Client Portal
Self-Hosting ยท ยท 12 min read

How to Run an Email Server on a VPS (and Whether You Should)

ยท 12 min read

Running your own email server on a VPS is one of the most satisfying self-hosting projects, and one of the least forgiving. The installation takes an afternoon. The hard part is getting your mail into Gmail and Outlook inboxes, and keeping it there.

This guide covers what you need before you start, the DNS records the big mailbox providers now expect, which software to use and how much server it needs, the setup in the right order, and an honest look at when hosted email is the better choice.

The short version

An email server on a VPS needs four things: an IP address with port 25 open and a clean reputation, a reverse DNS (PTR) record that matches your mail hostname, SPF, DKIM and DMARC records for your domain, and a mail stack such as Mail-in-a-Box, Mailu, Mailcow or Stalwart. Setting it up is the easy part. Deliverability and maintenance are the ongoing job.

Why run an email server on a VPS?

What you gain

  • Your mailboxes sit on your own disk, in a jurisdiction you chose
  • Unlimited addresses, aliases and domains, with no per-user fees
  • Your mail is not held by a separate email provider
  • Full control over logs, retention and spam filtering

What you take on

  • Deliverability: building and protecting your IP address's reputation
  • Security updates, TLS certificates and backups
  • Watching blocklists and the mail queue
  • Fixing it yourself when something breaks at a bad time

One reassurance: an email server on a VPS does not need perfect uptime, because email is built to survive short outages. A server that cannot reach yours will queue the message and keep retrying, typically for several days, so a reboot or a brief failure rarely loses mail.

What you need before you start

Sort these out before you install anything. An email server on a VPS without them will not deliver reliably, however well the software is configured.

  • A dedicated public IPv4 address. Shared or NAT addresses make reverse DNS, reputation and direct delivery much harder, and are a poor fit for a mail server.
  • Port 25 open. Many providers block outbound port 25 by default to stop spam, so ask before you build anything.
  • Reverse DNS. A PTR record that maps your IP to your mail hostname, such as mail.example.com, with that hostname pointing back to the same IP. Your provider sets it. Configure your mail server to introduce itself with the same hostname in its HELO/EHLO greeting, so the name it announces, its DNS and its reverse DNS all agree.
  • A clean IP. Check the address on public blocklists such as Spamhaus before you send anything. An address with a bad history is easier to swap now than later.
  • A domain whose DNS you control. You will add five or six records to it.
  • Enough memory for the software you choose, covered below.

Five questions to ask a provider before you buy

  1. Is outbound port 25 available, and on which plans?
  2. Will you set reverse DNS to my mail hostname?
  3. Do I get a dedicated public IPv4 address?
  4. Does your acceptable use policy allow running a mail server?
  5. What happens if the IP I am given already has a poor mail reputation?

The DNS records that decide whether your mail arrives

Every receiving server checks these before it decides what to do with your message. The examples use a placeholder domain and IP.

Record What it does Example
A Points your mail hostname at the server mail.example.com to 203.0.113.10
MX Tells other servers where to deliver mail for your domain example.com MX 10 mail.example.com
PTR Maps the IP back to the hostname. Set by your provider 203.0.113.10 to mail.example.com
SPF (TXT) Lists the servers allowed to send mail for your domain v=spf1 mx -all
DKIM (TXT) Publishes the key that verifies your signed messages. Your mail software generates it selector._domainkey.example.com
DMARC (TXT) Tells receivers what to do when checks fail, and where to send reports v=DMARC1; p=quarantine; rua=mailto:[email protected]

These are no longer optional extras. Gmail began enforcing sender rules in February 2024, and Yahoo publishes the same baseline: every sender needs SPF or DKIM, valid forward and reverse DNS for its sending IP, and a spam complaint rate below 0.3%. Gmail also requires a TLS connection. Bulk senders need both SPF and DKIM and a DMARC policy of at least p=none, and their marketing or subscription mail must support one-click unsubscribe. Since 5 May 2025, Outlook.com has required SPF, DKIM and DMARC from domains sending more than 5,000 messages a day, and mail that fails can be rejected.

An email server on a VPS for yourself or a small team will never reach those volumes, but receiving filters reward senders who meet the rules anyway, so set up all three records from day one. For stronger transport security, MTA-STS tells other servers to require encryption when delivering to you, and DANE does the same through DNSSEC.

Choosing the software

You do not need to assemble a mail server from parts any more. These are the main open-source options, from the simplest to the most hands-on.

Mail-in-a-Box Easiest start

One setup script turns a fresh Ubuntu 22.04 server with at least 512 MB of RAM into a complete mail server, with webmail, spam filtering and certificates included. The catch is that it also wants to be the DNS server for your domain, which makes it opinionated and harder to customise.

Mailu Light and modular

A set of Docker containers built around Postfix, Dovecot and Rspamd, with webmail and an admin interface. It needs 1 GB of RAM and 1 GB of swap without the antivirus scanner, or 3 GB of RAM and 1 GB of swap with it.

Mailcow Most complete

The most feature-rich option: Postfix, Dovecot, Rspamd and SOGo groupware with calendars and contacts, plus a polished admin panel, all in Docker. It is also the heaviest: the minimum is 6 GB of RAM plus 1 GB of swap and 20 GB of disk before any mail is stored, and the project recommends 8 GB of RAM for around 5 to 10 users.

Stalwart Modern all-in-one

A newer server written in Rust that handles SMTP, IMAP, POP3 and JMAP itself instead of combining separate programs, with anti-spam, automatic certificates and DKIM key rotation built in. It has an open-source community edition and a paid enterprise edition.

Postfix and Dovecot by hand For experts

Building the stack yourself from Postfix, Dovecot and Rspamd gives you the most control and the most to maintain. Worth it if you already run mail professionally or want to learn how every part works.

How much server you need

Memory is what decides the plan for an email server on a VPS. Antivirus scanning is the biggest single factor, and processor power rarely matters for a handful of users.

Software Memory it needs Packetra plan that fits
Mail-in-a-Box 512 MB minimum Cloud VPS #2, 3 GB, or #1 on a longer billing cycle
Mailu without antivirus 1 GB plus 1 GB swap Cloud VPS #2, 3 GB, or #1 on a longer billing cycle
Stalwart No published minimum Cloud VPS #2, or #1 on a longer billing cycle, and watch usage
Mailu with antivirus 3 GB plus 1 GB swap Cloud VPS #3, 4 GB
Mailcow 6 GB plus 1 GB swap; 8 GB recommended for 5 to 10 users Cloud VPS #4, 7 GB, for a few users

The plans above reflect where we can open port 25: on Cloud VPS #2 and above, or on #1 with a longer billing cycle. Disk space depends on how much mail you keep. Even the smallest plan's 25 GB is plenty for a few people, but mailboxes with years of attachments grow faster than you expect.

Setting up an email server on a VPS, step by step

1Order the VPS and ask for port 25 and reverse DNS

Ask for both at the start, with the hostname you will use, such as mail.example.com. Everything else depends on them.

2Point your DNS

Create the A record for the mail hostname and the MX record for your domain.

3Harden the server

Use SSH keys only, apply updates, and make sure your firewall allows the ports your mail software lists, typically 25, 465, 587 and 993, plus 80 and 443 for webmail and certificates.

4Install the mail software

Follow its official guide to the letter. The defaults are chosen with deliverability in mind.

5Publish SPF, DKIM and DMARC

Your software generates the DKIM key for you. Start DMARC at p=none to collect reports, then move to p=quarantine once everything passes.

6Test before you rely on it

Send a message to a Gmail and an Outlook address and open the full headers. You want to see spf=pass, dkim=pass and dmarc=pass.

7Start slowly

A new IP has no reputation. Send normal personal mail for the first weeks, ideally to people who will reply, and never send bulk mail from it.

8Set up backups and monitoring

Back up mailboxes and configuration to somewhere other than the server, and keep an eye on blocklists and the mail queue so problems show up before your contacts tell you about them.

Deliverability: the part nobody warns you about

Even with every record correct, a new email server on a VPS can land in spam folders. Microsoft's filters in particular are often strict with IP addresses they have not seen before. Reputation builds with time and with consistent mail that people want to receive.

Two free tools help you see what the big providers see: Google Postmaster Tools shows how Gmail rates your domain, and Microsoft's Smart Network Data Services (SNDS) shows how Outlook.com rates your IP.

If outgoing mail keeps struggling, many self-hosters keep receiving and storing mail on their own server but send through a relay service. It works, but the relay then handles every message you send, which is a privacy trade-off to make knowingly.

What it does and does not do for privacy

An email server on a VPS keeps your stored mail off the big email platforms and lets you decide what is logged and for how long. Your VPS host still runs the hardware underneath, so choose one you trust and encrypt your backups. And it does not make email private by itself:

  • Mail you exchange with Gmail or Outlook users is also stored by Google or Microsoft.
  • Encryption between mail servers is usually opportunistic. If the other side does not support it, a message can travel unencrypted unless MTA-STS or DANE requires encryption.
  • Senders, recipients, times and subject lines travel in the headers and are visible to every server a message passes through.
  • Your domain and your server's IP are public by design. Our guide to anonymous domain registration covers keeping your name off the domain.
  • End-to-end encryption needs PGP or S/MIME on top. The server does not provide it.

When hosted email is the better choice

An email server on a VPS is not the right answer for everyone. Choose hosted email if you need business-critical mail delivered every time and have no time for deliverability work, or if you want to send newsletters or marketing mail, which belongs on a dedicated sending service and never on your own server's IP.

If you only need a few mailboxes on your own domain, you do not need a server at all. Our shared hosting includes email accounts: 3 on Base, 5 on Boost, and unlimited on Pro and Ultra. And if you want a VPS project with less upkeep, our list of things to do with a VPS has plenty.

An email server on a VPS at Packetra

Outbound port 25 is closed on our Cloud VPS by default, as it is at many providers. Open a ticket and we will open it on Cloud VPS #2 and above, or on #1 with a longer billing cycle, and we set the reverse DNS for your IP at the same time; both are done by our team rather than self-service. Every Cloud VPS has a dedicated IPv4 address, IPv6 is available, and you can run your server in Finland or Switzerland. If your domain uses our nameservers, you can manage its DNS records in the client portal, with DNSSEC support.

Two rules apply. Unsolicited and bulk email are prohibited under our acceptable use policy. And if your IP ends up on a blocklist, we will ask you to fix the cause and request delisting, and port 25 can be closed again until that is done. Signup takes an email address, you can pay in Bitcoin or Monero, and Cloud VPS #2 costs EUR 15.90 a month in Finland and EUR 22.90 in Switzerland.

FAQ

Can I run an email server on a VPS?

Yes. An email server on a VPS works well as long as the provider will open port 25 and set reverse DNS for your IP. Check both before you order, because some providers keep port 25 closed on certain plans.

Why does my email go to spam?

Usually one of four things: a missing or failing SPF, DKIM or DMARC check, reverse DNS that does not match your hostname, an IP address on a blocklist, or a new IP with no reputation yet. Check the headers of a test message first.

How much RAM does a mail server need?

From 512 MB for Mail-in-a-Box to 6 GB plus swap for Mailcow. Antivirus scanning is the biggest single factor: Mailu needs 1 GB of RAM without it and 3 GB with it.

Is self-hosted email more private?

Partly. It keeps your stored mail off the big email platforms, though your VPS host still runs the hardware. Messages you exchange with Gmail or Outlook users still end up on their servers, and headers travel with every message. For private content, add PGP or S/MIME.

Can I run a mail server from home instead?

Usually not well. Many home internet providers block port 25, and residential addresses are widely treated as unsuitable for sending mail directly, which is why most guides, including Mail-in-a-Box's, recommend a server in a data centre.

Sources

Last reviewed: 4 October 2026

Research note: Memory requirements are taken from each project's own documentation at the time of review and change between releases, so check the current figures before you order. Mailbox provider rules are summarised from their published sender guidelines.

Need Reliable Hosting?

Privacy-focused, anonymous, and built for people who value their data.