What the message looks like
postfix/smtpd[2210]: NOQUEUE: reject: RCPT from client.example.net[203.0.113.20]: 554 5.7.1 <user@example.org>: Relay access denied; from=<me@example.com> to=<user@example.org> proto=ESMTP helo=<client>Common causes
- The mail client or app does not authenticate, or uses port 25 where login is not offered. Use the submission port 587 with login.
smtpd_relay_restrictionslackspermit_sasl_authenticated, so even logged-in users are refused.- The recipient domain is yours, but it is not listed in
virtual_mailbox_domains,mydestinationorrelay_domains. - The sending host is a trusted internal machine, but its address is not in
mynetworks. - A typo in the recipient domain, or an MX record that points to this server for a domain it should not serve.
Check
- Relay and recipient rules in effect
postconf -n | grep -E 'smtpd_relay_restrictions|smtpd_recipient_restrictions|mynetworks' - Which domains does this server accept?
postconf -n | grep -E 'mydestination|virtual_mailbox_domains|virtual_alias_domains|relay_domains' - Is login enabled on the submission service?
postconf -P submission/inet/smtpd_sasl_auth_enable - The rejections in the log
Fix
- For your users, make them send through port 587 with STARTTLS and a login, not over port 25 without login.
- Allow logged-in users:
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination, and enablesmtpd_sasl_auth_enable = yeson the submission service inmaster.cf. - If the recipient domain should be delivered here, add it to
virtual_mailbox_domains(ormydestination), but to only one of them, thenpostfix reload. - For one trusted internal host, add only that address to
mynetworks. Never add wide ranges or0.0.0.0/0. - Send a test again and check that the log line is gone.
Typical scenario
A multifunction printer is supposed to send scans by email through the company Postfix. /var/log/mail.log shows NOQUEUE: reject: RCPT from unknown[192.0.2.44]: 554 5.7.1 boss@gmail.com: Relay access denied. The printer speaks port 25 without login, and its IP is not part of mynetworks. First clarify whether the device supports SMTP authentication on port 587. That is cleaner than an exception for its IP.
FAQ
Does this mean my server is an open relay?
No, the opposite. This message is the protection working. You only need to act if your own users or your own domain are being refused.
Why does it only happen for some recipients?
Mail to your own domains is accepted, mail to other domains needs authentication. So local recipients work, and external ones get this error until the client logs in.
How do I allow a LAN device safely?
Preferably with login via the submission port 587 and a dedicated user per device. If it can only do port 25, add only its single address to mynetworks, not the whole network. Then postfix reload and check the log to see whether sending goes through.
May I make mynetworks very broad?
No. An entry such as 0.0.0.0/0 turns the server into an open relay that spammers use to distribute mail. The result is blacklist entries and rejected mail even for legitimate senders. Every address in mynetworks should be deliberately trusted.
How do I check whether my server is an open relay?
Connect from an external machine with nc server 25 and try to send mail from a foreign sender address to a foreign recipient. At RCPT TO the server must refuse with 554 5.7.1 Relay access denied. If it accepts, action is needed.