Running mail on a VPS

Before you build a mail server, open a support ticket and ask about outgoing port 25 and reverse DNS for your server. Many useful mail setups, such as IMAP mailboxes, webmail and sending through a relay on port 587, do not depend on either.

Recommended start: P1, $3.95/mo

What should I ask support before building a mail server?

Two things decide whether your server can deliver mail directly to other domains, and both are best confirmed before you spend an evening on Postfix.

  • Outgoing port 25: direct server-to-server delivery uses TCP port 25. Ask support whether outgoing port 25 is available for your server and on what conditions.
  • Reverse DNS (PTR record): receiving servers check that your IP resolves back to your mail hostname. Reverse DNS is not self-service in the console, so ask support whether a PTR record can be set for your address.

Open the ticket from the console with the server name. Until you have an answer, build the parts below that work either way: mailbox storage, IMAP, webmail and sending through a relay.

Which mail setups work well on a VPS?

The setups that send through a relay or only store mail are the easiest to run and the most reliable for deliverability:

  • IMAP mailbox server: Dovecot stores mail on your NVMe disk and serves it to phones and desktop clients on port 993. Mail arrives through a forwarding or fetch service you already use, or through your own MX once support confirms the port questions.
  • Outbound through a relay: Postfix hands all outgoing mail to an email relay service on port 587 with authentication. The relay handles reputation and delivery; your server stays simple.
  • Webmail: Roundcube or SnappyMail in front of Dovecot gives you browser access to your mailboxes.
  • Newsletters and list servers: listmonk or Mailman 3 manage subscribers, archives and bounces, and send through the relay at whatever volume the relay plan allows.
  • App mail: password resets and order notices from your web apps, sent through the same relay.

Plans that fit

Sizes picked for this project, smallest first. Prices are per month; the order total is the shortest term that reaches $40.

PlanWhySizePer monthOrder from
P1A Postfix relay client for app and server notices1 vCPU, 1 GB RAM, 20 GB NVMe$3.95$47.40 for 12 months
P2IMAP, webmail and spam filtering for a family or small team1 vCPU, 2 GB RAM, 40 GB NVMe$6.95$41.70 for 6 months
S4Adds ClamAV virus scanning in Europe2 vCPU, 4 GB RAM, 40 GB NVMe$4.25$51.00 for 12 months
S8Mailboxes for 20~50 people plus a list server4 vCPU, 8 GB RAM, 80 GB NVMe$6.35$76.20 for 12 months

How much server does a mail system need?

Mail is light on CPU; the heavy parts are spam filtering and virus scanning.

StackMemoryPlan
Postfix relay client for app mail onlyunder 200 MBP1
Postfix, Dovecot, Rspamd, Redis, webmail1~1.5 GBP2
Same plus ClamAV virus scanning2.5~3.5 GBS4
Mailboxes for a team of 20~50 with listmonk3~5 GBS8

ClamAV alone holds its signature database in memory, about 1~1.5 GB, so skip it on small plans or scan only attachments. Disk is usually the deciding size: estimate 2~5 GB per active mailbox per year.

How do I send through a relay with Postfix?

Install Postfix as a satellite system and point it at your relay:

apt -y install postfix libsasl2-modules
postconf -e "relayhost = [smtp.relay.example]:587"
postconf -e "smtp_sasl_auth_enable = yes"
postconf -e "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd"
postconf -e "smtp_sasl_security_options = noanonymous"
postconf -e "smtp_tls_security_level = encrypt"
echo "[smtp.relay.example]:587 username:password" > /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd && postmap /etc/postfix/sasl_passwd
systemctl restart postfix

Test with echo test | mail -s test you@example.com and read /var/log/mail.log. Because the relay sends from its own servers on its own port, this works without outgoing port 25 on your VPS.

Which DNS records does a mail domain need?

Four records make your mail trusted by receiving servers, whichever way you send:

  • SPF: a TXT record listing who may send for your domain, for example v=spf1 include:relay.example ~all when using a relay.
  • DKIM: a public key in DNS that matches the signature on each message. Relays give you the record; Rspamd can sign mail from your own server with rspamadm dkim_keygen.
  • DMARC: a TXT record at _dmarc.example.com, starting with v=DMARC1; p=none; rua=mailto:dmarc@example.com and tightening to quarantine once reports look clean.
  • MX: only if this server receives mail for the domain directly.

Our DNS guide shows where these records go at your registrar.

How do I set up Dovecot and webmail?

Dovecot gives clients secure IMAP access to the mailboxes:

apt -y install dovecot-imapd dovecot-lmtpd certbot
certbot certonly --standalone -d mail.example.com

In /etc/dovecot/conf.d/10-ssl.conf set ssl = required and point ssl_cert and ssl_key at the certificate files in /etc/letsencrypt/live/mail.example.com/. In 10-mail.conf use mail_location = maildir:~/Maildir. Open ufw allow 993/tcp and keep port 143 closed. Then install Roundcube or SnappyMail behind Nginx with HTTPS (see Nginx with HTTPS) and point it at localhost:993.

How do I keep a mail server from being abused?

An open relay or a guessed password turns your server into a spam source within hours, so close those doors first.

  • Check that Postfix only relays for authenticated users and localhost: postconf smtpd_relay_restrictions should include permit_sasl_authenticated and end with reject_unauth_destination.
  • Run fail2ban with the postfix-sasl and dovecot jails.
  • Enforce long passwords on mailboxes, and rotate the relay credentials if one leaks.
  • Watch the mail queue with mailq; a sudden pile of outgoing mail is the first sign of a compromised account.

What does a mail setup cost?

A mailbox and webmail server on P2 is $6.95 a month, sold from $41.70 for 6 months. With ClamAV and more mailboxes, S4 in Europe costs $4.25 a month. Mail traffic is tiny; even a newsletter of 100,000 messages at 50 KB each is about 5 GB, far below 20 TB. Take the backup add-on for mailboxes ($0.85 a month on S4), because a lost Maildir cannot be downloaded again.

Mail server, answered

Is outgoing port 25 open on my server?

Please ask support from the console before you build. Port 25 and reverse DNS are handled case by case, and sending through a relay on port 587 works either way.

Can I set reverse DNS myself?

Reverse DNS is not a self-service setting in the console. Open a support ticket with the server name and the hostname you want, and support will tell you what is possible.

Can I use an all-in-one mail suite?

Yes, suites such as Mailcow or Mail-in-a-Box install on Ubuntu or Debian. Plan for at least S4 because they include ClamAV, and settle the port 25 question first if they will send directly.

Will my mail land in spam?

Deliverability depends on SPF, DKIM, DMARC, sending volume and reputation. Sending through an established relay with all three records set gives the best start.

How much disk do mailboxes need?

A typical active mailbox grows 2~5 GB a year with attachments. S8 has 4 vCPU, 8 GB RAM, 80 GB NVMe, enough for a team for several years.

Build it on CheapVPS

Pick the plan, a city near your users and the image, then pay the order in crypto.