Skip to content
VDS · Apps and bots

Mail server: why it's difficult and what to consider

Why outgoing mail ports are closed and how to open them, what to configure so emails are delivered — PTR, SPF, DKIM, DMARC — and when you shouldn't run your own mail server.

Updated August 23, 2026

Setting up a mail server is not technically difficult — the hard part is getting your emails into the “Inbox” rather than spam, and avoiding silent bounces. This article covers what you need to do before sending your first email.

Why this is a separate task

Receiving email works almost immediately: you set up a server, open port 25, and messages arrive. The problem is sending, and it has two parts. First, outbound mail ports are closed by default on our platform and are opened on request. Second, the receiving side (Gmail, Mail.ru, Yandex) checks the sender against several criteria, and failing any one of them turns the message into spam or a rejection.

At minimum, the following is checked:

What is checkedWhere to configureWhat happens without it
Whether outbound port 25 is openSupport requestEmails do not go out at all
Reverse DNS (PTR)“Access” tab in the machine panelRejection at the connection stage
SPFDomain DNSEmail goes to spam
DKIMDomain DNS + mail serverEmail goes to spam
DMARCDomain DNSDomain is easy to spoof
IP reputationSending historySilent filtering

Setup order

  1. Request outbound ports. Ports 25, 465, and 587 are closed for outbound traffic until they are opened at your request. Start here: without this, you cannot test the rest, as described below.
  2. PTR. The reverse DNS record must match the name the server presents in SMTP. Set it in the machine panel on the “Access” tab, for example mail.example.com, and create a matching forward A record pointing to the machine's address.
  3. Mail stack. The easiest option is a ready-made containerized setup — docker-mailserver or Mailcow. It is installed via Docker Compose and will bring up Postfix, Dovecot, antispam, and DKIM keys itself.
  4. DNS. Create an MX record for the server name, then SPF and DMARC:
example.com.        MX  10 mail.example.com.
example.com.        TXT "v=spf1 mx -all"
_dmarc.example.com. TXT "v=DMARC1; p=quarantine; rua=mailto:postmaster@example.com"
  1. DKIM. The mail server generates the key; you publish the public part as a TXT record <selector>._domainkey.example.com.
  2. Verification. Send an email to a testing service (mail-tester, learndmarc) and aim for a full score. Do not send any bulk mail before this.

Outbound mail ports are closed by default

This is the main thing to know before installing a mail server. Outbound traffic from the machine to ports 25, 465, and 587 is blocked on the host. Sending email externally from a new machine does not work and will not start working because of settings inside the system: packets do not leave its network interface.

You can check it like this — the connection will not be established:

nc -vz smtp.gmail.com 25

This is done because a compromised machine starts sending spam first, and all neighbors on the host have to answer for the address and its reputation. This does not affect receiving email: incoming connections to 25, 465, 587, and 993 are not blocked, and the mail server accepts messages immediately.

How to open them

Ports are opened on request, manually, and not instantly. There is no button for this in the panel.

  1. Write to support with the machine number (the “Payment” tab, “For support” block).
  2. Describe what you are sending: domain, nature of the emails, approximate daily volume.
  3. Wait for a response. While the ports are closed, you can install and configure the mail server — but you cannot test sending.

Bulk mailings to purchased databases are not opened under any explanation; see What you can and cannot do on a machine.

If you need sending today rather than after a back-and-forth, use an external relay: a mail service provides an SMTP login and accepts connections on port 2525 or via API, and port 25 is not needed.

Firewall inside the machine

On your side, allow incoming connections to the mail ports:

sudo ufw allow 25/tcp
sudo ufw allow 587/tcp
sudo ufw allow 465/tcp
sudo ufw allow 993/tcp

ufw rules control only what enters your system. The block on outbound 25, 465, and 587 is external, and ufw allow out does not remove it.

Never leave an open relay. Check: swaks --to test@example.com --server <machine-address> from another machine without authentication — the connection should be rejected. An open relay turns the machine's address into a spam source within a day and destroys its reputation forever.

When you do not need your own mail server

  • You only need to send notifications from an application — use an external sending service. It is cheaper and has better deliverability. Connect to it via HTTP API or an alternative port such as 2525: standard ports 465 and 587 are closed just like 25.
  • You need email on a domain for people — mail hosting will solve the task without your involvement.
  • You are not ready to monitor updates and the queue — an abandoned mail server becomes a security hole.

Your own server is justified when independence matters and you are ready for maintenance: backups of mailboxes are mandatory, and you need to allocate disk space for mail with a margin — see disk space.