New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
SecurityUpdated 26 Oct 2026

Open Mail Relays: How to Test for One, Why It Is Dangerous and How to Close It

What an open relay is, how attackers find and abuse them, how to test your own server safely, common causes in Postfix, Exim and application servers, how to close the hole, and how to get delisted afterwards.

SQ
Written by Sana Qureshi
Email Compliance Specialist
Reviewed by Jonas Lindqvist
  • Published5 May 2025
  • Read time6 min
  • Length1,244 words
Share this guide

An open relay is a mail server that will accept a message from anyone and deliver it to anyone, regardless of who is sending or who the recipient is. In the early days of the internet that was normal courtesy. Today it is an invitation to spammers, who find open relays within hours using automated scans and use them to send enormous volumes of mail that appear to come from the owner's server. The consequences are quick and severe: blocklists list the server's IP address, mailbox providers reject its mail, the provider may suspend the hosting account and legitimate messages stop flowing. This guide explains what a relay is and what makes it open, how to test your own servers safely, the typical misconfigurations in Postfix, Exim and other software, how to fix them, how to deal with the aftermath and how to keep checking. It complements relay access denied errors, SMTP IP allowlists and Postfix relay setup.

DefinitionA server that accepts mail from unauthorised senders for unrelated recipients and forwards it
RiskSpam abuse, blocklisting, suspended hosting and damaged reputation
TestTry to send from outside your network to an outside recipient; it must be refused
FixRestrict relaying to authenticated users and trusted networks, and require authentication on submission ports

What relaying means

A mail server plays several roles. For its own domains, it accepts mail and delivers it to local mailboxes: that is receiving, and it must accept mail from anywhere. For authorised users, it accepts mail addressed to other domains and forwards it onward: that is relaying, and it must be restricted. A server is an open relay when it performs the second role for strangers. The distinction is the recipient: mail from anyone to a local recipient is acceptable; mail from anyone to a non-local recipient is not.

ScenarioSenderRecipientShould the server accept?
Incoming mailAnyoneLocal mailboxYes
Outgoing mail from a logged-in userAuthenticated userAny domainYes
Outgoing mail from a trusted application serverTrusted network addressAny domainYes, if the network is truly trusted
Mail from a stranger to an outside domainUnauthenticated, untrustedAnother domainNo: this is relaying and must be refused with 5xx. See relay access denied

How attackers find and use them

  • Scanners probe addresses across the internet on port 25 and the submission ports, and test whether a message can be relayed.
  • A successful test places the server on shared lists of open relays that spammers use.
  • Spam runs follow, typically bursts of thousands of messages, sometimes with forged sender addresses at your domain.
  • Your IP address is reported and listed. Microsoft, Google and Yahoo begin rejecting mail from it.
  • The server may be used for phishing and fraud, which could involve legal or contractual consequences for the owner.

Testing your own server safely

Test from a machine outside your network, using an address you control as the recipient. Never test by sending to third parties. A manual test uses the SMTP dialogue and checks whether the server accepts a recipient in a different domain:

$ openssl s_client -connect mail.example.com:25 -starttls smtp -crlf -quiet
EHLO tester.example.net
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
; A correct server answers: 554 5.7.1 Relay access denied (or 550 5.7.54)
; A vulnerable server answers: 250 2.1.5 Ok

Also test with these variations, which exploit parsing mistakes in older or poorly configured systems:

  • The recipient with a percent sign (user%[email protected]) and with the bang path ([email protected]).
  • A sender address at your own domain (MAIL FROM:<[email protected]>), because some servers trust it.
  • Empty sender (MAIL FROM:<>), then a non-local recipient.
  • Connect from various network positions: the public internet, your office and your hosting provider's network, because some "trusted" ranges are broader than expected.
  • Test every port that accepts SMTP: 25, 465, 587 and any alternative.

Online relay-test tools exist and do the same checks from outside. Use well-known services and, because they send a test message through your server, only on servers you own. Record the results and repeat after configuration changes. See testing SMTP connections.

Common causes

SoftwareMisconfigurationFix
Postfixmynetworks set too wide (for example 0.0.0.0/0 or a whole cloud range)Restrict to loopback and specific trusted addresses
Postfixsmtpd_recipient_restrictions missing reject_unauth_destination, or permit before itEnsure the restrictions end with reject_unauth_destination and appear in the right order
Postfixsmtpd_relay_restrictions permitting everythingUse permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
Eximrelay_from_hosts or hosts_relay too broad; ACL accepting accept without conditionsLimit to specific hosts; require authentication
SendmailOld versions with relaying enabled by default, or promiscuous_relay featureUpgrade and remove the feature
Application servers (PHP mail forms, scripts)A form that accepts a recipient from user input; header injectionFix the script. See protecting forms
Hosted gateways and appliancesAllow rules for "any" sourceReview rules; limit to known sources
Containers and cloudSMTP port exposed publicly to a service that was meant to be internalUse network rules to restrict access
Reverse proxies / port forwardingAll connections appear to come from the proxy, which is trustedPreserve client addresses or authenticate users
# Postfix: a safe baseline
mynetworks = 127.0.0.0/8 [::1]/128
smtpd_relay_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination
smtpd_recipient_restrictions =
    permit_mynetworks,
    permit_sasl_authenticated,
    reject_unauth_destination

Check the version you run, as parameter names and defaults differ. Reload the service after changing the configuration, and repeat the tests.

Hidden open relays: authenticated and indirect abuse

Even with correct restrictions, abuse can come through legitimate credentials. A compromised account, a weak password or a leaked application key lets an attacker relay through the proper door. Defend with strong secrets, rate limits and monitoring. See SMTP brute-force protection. A web form that sends mail to any address supplied by the visitor is an application-level relay, and needs the same attention. Also check backscatter: a server that accepts mail for nonexistent users and then bounces it back to forged senders acts as an unintended relay for spam. Reject unknown recipients during the SMTP conversation instead.

If you were an open relay

  1. Close the hole first and verify with tests. Cleaning up before closing it is pointless.
  2. Stop the flow. Review the queue for spam and remove it by ID after inspection. See mail queue management.
  3. Review logs to determine the period and volume of abuse, and which sender and recipient patterns were used.
  4. Rotate credentials if any account was involved.
  5. Check blocklists using the blocklist check, and follow each list's removal process once the problem is fixed. See blocklist removal.
  6. Tell your hosting provider what happened and what you did, if they raised the issue.
  7. Monitor complaints and reports for several weeks. See abuse mailboxes.
  8. Document the incident and add periodic relay tests to your routine.

Preventive routine

  • Test for relaying after every mail-server configuration change and software upgrade.
  • Schedule an automated external relay test monthly, with an alert on failure.
  • Review network trust lists quarterly, and remove addresses that no longer need access.
  • Require authentication and TLS on submission ports. See which SMTP port to use.
  • Rate-limit outbound mail per client and per account.
  • Keep software patched, and subscribe to security announcements of your MTA.
  • Use a managed relay where you do not need to run mail infrastructure yourself.

Closing an open relay takes minutes; the damage from leaving it open takes months to repair. Test it, fix it and keep testing.

Skip the server hardening Use a managed relay with authentication and abuse controls built in.

Explore the SMTP relay

References and further reading

Frequently asked questions

What is an open relay?

A mail server that accepts mail from unauthorised senders for recipients on other domains and forwards it onward.

How do I test whether my server is an open relay?

From outside your network, try to send from an external sender to an external recipient you control. A correct server refuses with a 5xx relay denied error.

What causes Postfix to relay for everyone?

Usually mynetworks set too broadly, or missing reject_unauth_destination in the relay restrictions.

Can a server with authentication still be abused?

Yes, through stolen or weak credentials. Use strong secrets, rate limits and monitoring.

What should I do first if I found an open relay?

Close it and verify, then clear the spam queue, rotate credentials, check blocklists and monitor.

Topics#open relay#smtp security#postfix#exim#blocklists
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales