An open relay accepts mail from anyone and sends it anywhere: neither the sender nor the recipient needs any connection to the server. Spammers use such servers to send mail at someone else’s expense, and the server’s reputation is quickly destroyed.
Why it is dangerous
- The server’s IP address ends up on DNS blocklists, and legitimate mail from its users is rejected.
- The queue fills with thousands of other people’s messages, and disk and bandwidth are consumed by the mailing.
- The provider blocks outbound port 25 or shuts the server down after complaints.
- Undeliverable messages are bounced as notifications to forged addresses.
What the server should check
A closed server decides on two things: who connected and who the message is addressed to. It is not obliged to accept third-party mail for third-party domains.
| Client | Recipient | Decision |
|---|---|---|
| from its own network or logged in with a password (SASL) | any address | accept and forward |
| an outsider | an address in this server’s domain | accept: this is incoming mail |
| an outsider | an address in another domain | reject: “Relay access denied”; with defer_unauth_destination, a temporary 454 code |
In Postfix, this is set by the smtpd_relay_restrictions parameter. The default value already closes the relay, but mistakes in mynetworks open it again: writing mynetworks = 0.0.0.0/0 is enough to make the whole internet “your own network”.
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destinationmynetworks = 127.0.0.0/8 [::1]/128How to test it
Test from an outside address, not from the server itself: to itself, a server is always “local”. The swaks utility tries to send a message from one external domain to another, and a closed server must refuse.
swaks --server mail.example.com --from a@example.org --to b@example.netThe summary of RFC 2505 (BCP 30, 1999) opens with a call to stop unauthorised mail relaying.
Sources
the term is written from these pagesVerified 9 Nov