Wakali Blog
← Back to Blog Self-Hosting

Why (and How) to Self-Host Your Own Email Server

If you're already paying for a VPS, you might be paying twice for email you could host yourself. Here's what self-hosted mail actually involves, and what you'll need before starting.

K
Kevo Mkali
15 Aug 2026 · 5 min read

If you already run a VPS for a website or application, there is a reasonable chance you are also paying a separate company solely to handle your email. That arrangement is common, largely because self-hosted email has a reputation for being difficult to get right. In practice, the core components — Postfix, Dovecot, and a handful of DNS records — are more approachable than that reputation suggests, and understanding how they fit together is useful knowledge well beyond email itself.

This is the first post in a three-part series covering the whole process: the case for self-hosting email, how to install and configure the software correctly, and — the part most guides skip — how to ensure your mail actually reaches the inbox rather than the spam folder.

A few terms, defined once

This series assumes no prior experience with servers or email infrastructure. A handful of terms come up repeatedly, so it's worth defining them clearly once rather than assuming familiarity:

  • VPS (Virtual Private Server) — a remote computer you rent, that runs continuously and that you access over the internet, typically via SSH. This is where all of the software in this series gets installed and runs.
  • SSH — the standard way to open a secure command-line session on a remote server. Every command shown in this series is typed into an SSH session connected to your VPS, not into your own laptop.
  • sudo — a command that runs whatever follows it with administrator ("root") privileges. Installing and configuring server software almost always requires this.
  • DNS (Domain Name System) — the system that maps human-readable domain names, like example.com, to the information other computers need to reach or verify them — an IP address, a mail server, or in some cases just a piece of text. You manage DNS through whichever company you registered your domain with, or a separate DNS provider.
  • DNS record — a single entry in that system. The types that matter for this series are A (points a name at an IP address), MX (points a domain at its mail server), and TXT (stores arbitrary text, used here for verification and authentication data).
  • TLS certificate — the credential that lets a server prove its identity and encrypt traffic; the padlock icon in a browser's address bar represents this. Mail servers use the same technology to encrypt connections between them.

Nothing else in this series assumes knowledge beyond these. Where a more specific term comes up later, it's explained at the point it's introduced.

What you are actually installing

A "mail server" is not one large, complex system. It is three small programs, each with a single, well-defined responsibility:

  • Postfix is the SMTP server. SMTP is the protocol used to transfer mail between servers: when someone sends you an email, their server delivers it to yours over SMTP. Postfix also handles outbound mail — when an application sends a notification email, Postfix is what actually dispatches it.
  • Dovecot is the IMAP server. IMAP is how mail clients — a desktop client, a phone's mail app, a webmail interface — read mail that has already been delivered. Postfix receives a message and writes it to disk; Dovecot is what makes that message readable.
  • OpenDKIM cryptographically signs outgoing mail, so receiving servers can verify that a message claiming to be from your domain genuinely is, and was not altered in transit. Without this, most mail providers will quietly treat your messages as suspicious.

That is the entire system: three programs, each doing one clearly-scoped job, configured to work together.

Why self-host at all

A few reasons this is worth doing, beyond simply being possible:

  • You likely already have the infrastructure. A VPS capable of running a web application is capable of running a mail server. This is a matter of using capacity you already have, not acquiring something new.
  • You control your own deliverability. With a third-party provider, your mail's reputation depends on their infrastructure, their other customers, and their uptime. Self-hosting puts the DNS records that determine whether your mail is trusted entirely in your own hands.
  • It builds real understanding. SMTP, DNS, TLS, and authentication are foundational concepts that reappear throughout infrastructure work generally, not just in email.

It is also worth being direct about the actual risk. If you already have live mail flowing through an existing provider, the dangerous part of this project is not the software installation — it is the cutover. A careless DNS change can silently drop incoming mail during the transition, and you may not find out until a customer mentions it. The final post in this series covers a cutover approach designed specifically to avoid that outcome.

What you will need

  • A VPS running Ubuntu or a comparable Linux distribution, with root or sudo access, reachable over SSH
  • A domain name with DNS you control — several records need to be added over the course of this series
  • Roughly an afternoon, working through the steps in order

Every command in this series is meant to be typed into an SSH session connected to that VPS — not into your own computer's terminal. If you haven't connected to a server over SSH before, most VPS providers document the exact command for their platform; it typically looks like ssh root@YOUR_SERVER_IP.

A working website on that same server is not a prerequisite. The mail server is entirely independent software; it simply happens to run well alongside one.

What comes next

The next post installs and configures Postfix, Dovecot, and OpenDKIM on a bare server, with every command explained rather than simply listed — including a TLS-certificate permissions issue that catches nearly everyone attempting this for the first time, because the underlying cause is not obvious unless you understand exactly how Postfix and Dovecot each handle system privileges.

The final post covers what actually determines whether the project succeeds: configuring SPF, DKIM, and DMARC correctly, testing the setup properly before it handles real traffic, and a safe, ordered process for switching a live domain over without losing mail along the way.