// how to fix
Your mail server is an open relay
An open relay lets anyone on the internet send email through your server. Spammers find it within hours and your IP ends up blacklisted.
What it means
A mail server has two normal jobs: accept email for your own domains, and send email for your own users after they log in. An open relay does a third thing: it accepts email from anyone, to anyone, and passes it on. Spammers scan the internet constantly for such servers and use them to send huge volumes in your name.
Why it matters
- Your IP is added to blacklists quickly, and then even your normal emails are refused.
- Your hosting company may suspend the server for abuse.
- Your server's resources and bandwidth are used by strangers.
How to check
- Look at your mail queue. A large queue full of emails you did not send is a strong sign. In Postfix:
mailq. - Read
/var/log/mail.logfor unknown senders sending to many outside addresses. - Check your IP at
/blacklists. - Test from another machine outside your network. Connect with
telnet mail.yourdomain.com 25, then type:HELO test.example.com MAIL FROM:<someone@example.com> RCPT TO:<someone-else@example.org>
A safe server refuses the last line with an error like554 5.7.1 Relay access deniedor454 4.7.1. If it answers250, it is an open relay. TypeQUITwithout sending anything.
How to fix it
Postfix
- Limit trusted networks to the server itself in
/etc/postfix/main.cf:mynetworks = 127.0.0.0/8 [::1]/128
Never put0.0.0.0/0or a large public range here. - Only allow trusted networks and logged-in users to relay:
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination
- Make sure
relay_domainslists only domains you really handle. - Reload:
postfix reload.
Other servers
Exim, Exchange, hMailServer and others have the same idea under different names: look for "relay", "allowed IPs" or "trusted networks" and allow only authenticated users and localhost.
Also check for stolen accounts
Sometimes the server is not open, but a mailbox password was stolen and spam is sent with a real login. The log then shows a username next to each spam. Change that password, check for weak passwords on all accounts, and consider tools like fail2ban that block repeated login attempts. Old website scripts or contact forms can also be abused to send spam.
Clean up
- Remove the spam from the queue. In Postfix,
postsuper -d ALL deferreddeletes deferred messages; check carefully that no real emails are waiting. - Check your IP again at
/blacklistsand request removal from each list once the problem is fixed. The paid dashboard's blacklist removal tools can help track this.
Check that it is fixed
Repeat the telnet test from outside: the RCPT line to an outside address must be refused. Then send a normal email from a real account to your test address on the home page (/) to confirm that legitimate sending still works and no blacklist is reported.
Check that it is fixed
DNS changes can take from a few minutes to a few hours. Then send a new test email or scan your domain again.
Related guides
- Move DMARC from p=none to quarantine or reject safelyp=none only watches. To really stop fake emails using your domain, move step by step to quarantine and reject, without blocking your own emails.
- Your sending IP address is on a blacklistA blacklist is a public list of IP addresses known for sending spam. Find out if the IP is yours, fix the cause, then ask for removal.
- Your domain is on a blacklist (Spamhaus DBL, SURBL, URIBL)Domain blacklists list domain names seen in spam. They follow your domain wherever you send from. Find the cause, clean up, then request removal.
- Bounce "550 5.7.1": message rejected or blocked by policyA 5.7.1 bounce means the receiving server refused your email on purpose. Learn to read bounce messages, find the real reason and fix it.
- Protect your incoming mail with MTA-STS and TLS-RPTMTA-STS forces other servers to use encryption when they deliver email to your domain. TLS-RPT sends you reports when that fails. Both are optional but recommended.