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) ofRCPT TOfor 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_destinationmynetworkscontains only addresses you really trust. Adding the provider's whole network or0.0.0.0/0creates an open relay.permit_sasl_authenticatedlets users send after logging in.defer_unauth_destination(orreject_unauth_destination) refuses to relay to domains the server does not handle.
Good practice regardless of software:
- User submissions on port 587 (submission) with login and encryption; port 25 only for receiving mail from the internet.
- Devices and applications (printers, ERP systems) send through a server with login, not through an open relay on the local network.
- 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).
- The server refuses to relay mail from an outside domain to an outside domain without login.
mynetworkscontains only trusted addresses.- Users and devices send through port 587 with login.
- 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.
MailSpecto Engineering Team
We build tools for email address verification, deliverability monitoring and mail infrastructure security diagnostics for companies in Poland and Europe.