MailSpecto
Cybersecurity 3 min read

Open relay – how to check that your mail server is not open

An open relay is a mail server that passes on mail from anyone to anyone. Spammers find such servers automatically, and their addresses quickly end up on blocklists. We explain how the test works, how to check your own server safely and how to secure it.

MailSpecto Engineering Team

Mail infrastructure and deliverability

Outside sender to outside domain Your server RCPT TO, no DATA 554 5.7.1 Relay access denied Result server is closed

1. What is an open relay?

A mail server has two jobs:

  • accept mail for its own domains from anyone on the internet;
  • send mail to other domains, but only for its own (logged-in) users or from trusted addresses.

An open relay is a server that sends mail to other domains for anyone, without logging in. A spammer connects to it and sends thousands of messages that look as if they come from your infrastructure. The consequences:

  • the server's IP address ends up on blocklists and your own mail stops getting through;
  • the server is overloaded and the connection saturated;
  • your company may have to answer for someone else's spam.

Today the default configurations of popular servers are not open, but open relays still happen: after manual changes, with too broad a list of "trusted networks", or on forgotten devices (printers, old gateways, application servers).

2. What the test looks like

The test tries to relay a message from an outside domain to an outside domain and stops before the content:

EHLO test.example
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
554 5.7.1 <[email protected]>: Relay access denied
QUIT
  • A refusal (554 5.7.1 Relay access denied, 550 5.7.1 Unable to relay) means the server is safe.
  • Acceptance (250 OK) of RCPT TO for an outside domain means an open relay. Nothing needs to be sent to establish that.

Only test your own servers

Trying to relay mail through someone else's server may be treated as an attack. Test servers you manage or have written permission to test. Never send the DATA command in a test.

3. How to secure the server

In Postfix, the key is restricting relaying in smtpd_relay_restrictions:

# /etc/postfix/main.cf
mynetworks = 127.0.0.0/8 [::1]/128
smtpd_relay_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    defer_unauth_destination
  • mynetworks contains only addresses you really trust. Adding the provider's whole network or 0.0.0.0/0 creates an open relay.
  • permit_sasl_authenticated lets users send after logging in.
  • defer_unauth_destination (or reject_unauth_destination) refuses to relay to domains the server does not handle.

Good practice regardless of software:

  1. User submissions on port 587 (submission) with login and encryption; port 25 only for receiving mail from the internet.
  2. Devices and applications (printers, ERP systems) send through a server with login, not through an open relay on the local network.
  3. After every configuration change, repeat the test from outside.

4. The open relay test in MailSpecto

The MailSpecto mail server analysis includes an optional open relay test. It only works for domains whose ownership you verify with a TXT record, connects only to the public addresses of the domain's MX servers, ends the conversation at RCPT TO (it never sends DATA) and uses a recipient in the test operator's own domain. The same analysis checks STARTTLS, the certificate, TLS versions, AUTH before encryption and reverse DNS (PTR).

  1. The server refuses to relay mail from an outside domain to an outside domain without login.
  2. mynetworks contains only trusted addresses.
  3. Users and devices send through port 587 with login.
  4. Repeat the test after every configuration change, only on your own servers.

Keep your contact list clean

Verify email addresses before you send, and explore our upcoming SPF/DKIM/DMARC diagnostics module.

Try MailSpecto

MailSpecto Engineering Team

We build tools for email address verification, deliverability monitoring and mail infrastructure security diagnostics for companies in Poland and Europe.

Related articles

Cybersecurity

MTA-STS and TLS-RPT – how to enforce encryption for incoming mail

How MTA-STS enforces TLS for incoming mail, how to publish the policy and how to enable TLS-RPT reports.

Read article →
Cybersecurity

What is backscatter spam and how to protect your mail server

How to avoid sending false bounce messages (NDRs) from your server, and what to do when you are the victim of backscatter.

Read article →
Compliance

Article 24 of the Polish anti-abuse act – what public bodies must do about email

Who Article 24 of the Polish UZNKE covers, what it requires from public bodies and email providers, the new definition of a public entity from 3 April 2026, inspections by the UKE President, penalties and a checklist.

Read article →