Guideschevron_rightServers

Servers · 10 min read · Updated

How to Run Your Own Mail Server on a Dedicated Server

To run your own mail server, use a dedicated server, where outgoing port 25 is open, and install mailcow, a Docker-based mail suite with Postfix, Dovecot, spam filtering and webmail. Ask us to set reverse DNS for the server's address to your mail hostname, add A, MX, SPF, DKIM and DMARC records, run mailcow's installer, change the default admin password and add your domains and mailboxes. mailcow needs at least 6 GiB of memory plus swap. Our dedicated servers start at $399.00 a month.

VPS or Dedicated Server for Email

Sending email from a VPS compared with a dedicated server
ServerOutgoing port 25How mail is sent
VPSBlockedThrough a relay on port 587 or 465
Dedicated serverOpenDirectly to other mail servers, or through a relay

A VPS still suits mailcow when you are happy to send through a relay: the Bronze VPS (6 GB) meets mailcow's minimum, and 8 GB or more its recommendation for 5 to 10 users. The rest of this guide assumes a dedicated server delivering directly.

Dedicated servers, cheapest configuration of each processor
ProcessorMemoryStorageFrom
AMD Ryzen 9 5950X128 GB2x 1TB NVMe$399.00/mo
AMD Ryzen 9 9950X192 GB2x 2 TB NVMe$669.00/mo
AMD EPYC 4585PX128 GB2x 6.4TB NVMe Gen4$849.00/mo
AMD EPYC 7443P512 GB2x 2TB NVMe$969.00/mo
AMD EPYC 9455P512 GB2x 3.2TB NVMe$999.00/mo
AMD Dual EPYC 7702512 GB2x 2TB NVMe$1,099.00/mo
AMD EPYC 9455512 GB4x 3.2TB NVMe$2,299.00/mo

1. Reverse DNS and DNS Records

Pick a mail hostname such as mail.example.com. Open a support ticket and ask us to set the reverse DNS (PTR) of the server's IPv4 address to that name: many receiving servers reject or junk mail from an address whose reverse DNS does not match. Then add these records at your DNS provider:

DNS records for a mail server
RecordNameValue
Amail.example.comThe server's IPv4 address
MXexample.commail.example.com (priority 10)
TXT (SPF)example.comv=spf1 mx -all
TXT (DMARC)_dmarc.example.comv=DMARC1; p=quarantine; rua=mailto:[email protected]
CNAMEautodiscover and autoconfigmail.example.com
TXT (DKIM)dkim._domainkey.example.comCopied from mailcow after install (step 4)

If the mail hostname is behind a proxying service such as Cloudflare, set it to DNS only: mail cannot pass through a web proxy.

2. Prepare the Server

On Ubuntu 24.04 or Debian 13, secure the server and install Docker from Docker's own repository (mailcow needs Docker Engine 24 or newer and Compose 2). Make sure the clock is synchronised with timedatectl status, and that nothing else uses the mail or web ports:

ss -tlpn | grep -E -w '25|80|110|143|443|465|587|993|995|4190'

mailcow's documentation warns that ufw and firewalld can interfere with its containers; it publishes TCP 25, 465, 587, 143, 993, 110, 995, 4190, 80 and 443.

3. Install mailcow

sudo apt install -y git openssl curl gawk coreutils grep jq
cd /opt
sudo git clone https://github.com/mailcow/mailcow-dockerized
cd mailcow-dockerized
sudo ./generate_config.sh          # enter mail.example.com when asked
sudo docker compose pull
sudo docker compose up -d

The installer fetches a Let's Encrypt certificate for the mail hostname once DNS points at the server. On a smaller server, set SKIP_CLAMD=y and SKIP_FTS=y in mailcow.conf to leave out the virus scanner and full-text search, which use the most memory.

4. Sign In and Add Your Domain

  1. Open https://mail.example.com/admin and sign in with mailcow's default login, admin / moohoo. Change that password straight away and turn on two-factor authentication.
  2. Add your domain under the mail setup pages, then create the mailboxes.
  3. Copy the domain's DKIM key from mailcow into the dkim._domainkey TXT record.
  4. Send a test message to an outside address and check the headers show SPF, DKIM and DMARC as passed.

Keep It Delivering

  • Never leave the server as an open relay, and use strong mailbox passwords: a hijacked mailbox sending spam gets the address blocklisted.
  • Start with normal volumes; bulk newsletters belong on a service built for them.
  • Check your address on public blocklists now and then, and read DMARC reports for mail others send in your name.
  • Update with mailcow's ./update.sh after reading the release notes.
  • Back up with mailcow's backup script to another place, such as a storage box; mailboxes are hard to rebuild.

Just need a website or app to send mail? You do not need a mail server: see sending email from your server.

Common Questions

  • Can I run a mail server on a VPS?

    You can run one that receives email, but outgoing port 25 is blocked on every VPS, so it has to send through a relay (an email provider or transactional service) on port 587 or 465. A dedicated server is not blocked and can deliver email directly.

  • How much memory does mailcow need?

    mailcow's documentation gives a minimum of 6 GiB plus 1 GiB of swap for its default setup, recommends 8 GiB for about 5 to 10 users, and suggests 16 GiB for a company with around 50 concurrent IMAP connections. Turning off ClamAV and full-text search lowers that.

  • Why do my emails land in spam?

    Usually a missing or wrong record: reverse DNS that does not match the mail hostname, no SPF, no DKIM signature or no DMARC policy. A new address with no sending history also starts with little reputation, so send modest volumes at first.

  • Is running my own mail server worth it?

    It gives you full control over your domains, mailboxes and data, with no per-user fees. In return you own deliverability, spam filtering, updates and backups. For a handful of mailboxes a hosted provider is less work; for many domains or users, your own server pays off.

Plans and prices

Dedicated Servers

Bare-metal servers with outgoing port 25 open, for mail servers that deliver directly.

See all plans
  • AMD Ryzen 9 5950X

    16 Cores · 128 GB RAM · 2x 1TB NVMe

    Ashburn, VA · Dallas, TX · 50 TB transfer · 10 GigE

    $399.00/mo

  • AMD Ryzen 9 9950X

    16 Cores · 192 GB RAM · 2x 2 TB NVMe

    Ashburn, VA · Dallas, TX · 50 TB transfer · 10 GigE

    $669.00/mo

  • AMD EPYC 4585PX

    16 Cores · 128 GB RAM · 2x 6.4TB NVMe Gen4

    Dallas, TX · 200 TB transfer · 50 Gbps

    $849.00/mo

  • AMD EPYC 7443P

    24 Cores · 512 GB RAM · 2x 2TB NVMe

    Dallas, TX · Ashburn, VA · 50 TB transfer · 10 GigE

    $969.00/mo

Keep Reading

All guides