SMTP Relaying Denied: Complete Fix for Postfix, Exim, and Sendmail

Getting 550 5.7.1 Relaying Denied or 554 5.7.1 Relay Access Denied? Complete fix guide with Postfix, Exim, and Sendmail configuration for outbound relay authentication.
Alaa
By Alaa
SMTPedia documents email infrastructure end to end: SMTP standards from the RFC archive, delivera...
16 min read Updated Jul 23, 2026 147 views
PERMANENT FAILURE · X.7.x SECURITYFIX YOUR RELAY

SMTP response received

550 5.7.1 <user@domain>: Relay access denied

You received this code because your outbound SMTP server refused to forward the message. This is sender-side โ€” a problem with your own relay configuration, not with the recipient. Almost always caused by missing SMTP AUTH, the wrong outbound server, or an IP not on the relay allowlist. Fixable in minutes once identified.

๐Ÿ‘ค Who sees this code

  • Developer configuring transactional email in an app
  • Sysadmin setting up Postfix or Exchange relay
  • Team migrating to a new outbound SMTP provider

๐Ÿ”ง What this guide fixes

  • Distinguish sender-side relay-denied from receiver-side 5.7.1
  • Correct SMTP AUTH, port, and TLS configuration
  • Provider-specific fixes for Postfix, Exchange, Sendmail

๐Ÿ—‚ The 5.7.x security and policy family

โšก Do these 3 things first (before diving deeper)

1

Confirm SMTP AUTH is enabled and credentials are valid

Most 550 5.7.1 relaying denied errors happen because the client is not authenticating before RCPT TO. Open your mail library or application configuration and confirm SMTP AUTH is turned on, that the username matches an active account on the relay server, and that the password is current. Test with a smtplib.SMTP call in Python, telnet AUTH LOGIN, or your ESP outbound test tool. If authentication fails at handshake, relaying will always be denied and no amount of subsequent config changes will fix the underlying credential problem.

2

Verify you are connecting to the correct SMTP relay server

550 5.7.1 also appears when your app is trying to send through an SMTP server that is not authorized to relay for your domain. This happens after DNS migrations, provider changes, or accidental use of a public MX server as an outbound relay. Confirm the SMTP host in your config matches the outbound submission server documented by your provider (smtp.gmail.com, smtp.office365.com, smtp.sendgrid.net, etc.). Using a receiving-only MX server as an outbound relay is one of the most common misconfigurations.

3

Check the port and TLS mode you are connecting on

Modern SMTP relays require port 587 with STARTTLS for authenticated submission, or port 465 with implicit TLS for legacy configurations. Port 25 is reserved for server-to-server relay and typically does not accept AUTH from client applications. Many relays reject AUTH attempts on port 25 with 550 5.7.1 relaying denied. If your app is connecting on port 25 to send authenticated mail, switch it to 587 with STARTTLS and retry.

Common causes of 550 5.7.1

  1. SMTP authentication not enabled in your application. The single most common cause. Your mail client, transactional service, or custom code is trying to relay through an authenticated SMTP server without providing AUTH credentials. Modern relays never allow unauthenticated relay by default because open relays get instantly abused for spam. This affects everything from misconfigured smtplib scripts to legacy applications ported from environments that historically allowed open relay. The fix is always to enable SMTP AUTH and provide valid credentials in the connection.
  2. Connecting to the wrong outbound SMTP server. Some setups mistakenly point their outbound SMTP at a MX server (used for receiving mail) or at a generic public relay. These servers reject relay attempts with 550 5.7.1 because they are not configured to accept your outbound traffic. Confirm you are connecting to the outbound submission server documented by your email provider. Public MX records are for INCOMING mail: they do not accept outbound relay from client applications even with valid credentials.
  3. Sending IP not in the relay allowlist. For self-hosted Postfix, Exim, or Sendmail, unauthenticated relay is permitted only for IPs listed in mynetworks (Postfix) or the equivalent trusted-host configuration. If your application server is sending unauthenticated from a new IP that was never added to the trusted list, the relay rejects with 550 5.7.1. This surfaces after infrastructure moves, container restarts on new IPs, or firewall changes that shift outbound routing to a different source address.
  4. Expired or rotated SMTP credentials. Passwords rotate on schedules. API keys expire. Service accounts get disabled during quarterly access reviews. Your application keeps sending with credentials it was configured with, gets 550 5.7.1 as the relay refuses the AUTH handshake, and your team spends an hour debugging routing before checking the credentials themselves. Always verify credentials before deeper investigation: a fresh authentication test takes seconds and eliminates the most common trivial cause.
  5. Sending domain not in Accepted Domains (Exchange). For self-hosted Exchange or hybrid Microsoft 365 setups, mail can only be relayed for domains explicitly listed in Accepted Domains. If your organization added a new subdomain or acquired a new company domain without updating Exchange configuration, sends from that domain hit 550 5.7.1 or the closely related 550 5.7.54 (unable to relay in non-accepted domain). The fix is to add the domain to Accepted Domains via Exchange Admin Center or PowerShell before retrying.

How to fix 550 5.7.1, step by step

  1. Enable SMTP authentication in your sending application. In most mail libraries (nodemailer, smtplib, PHPMailer, Mail::Sender), SMTP AUTH is a simple config flag: pass a username and password to the constructor and set secure to true for TLS. For custom code using raw sockets, implement the AUTH LOGIN or AUTH PLAIN exchange after EHLO. If you are unsure whether AUTH is happening, add SMTP debug logging temporarily and observe the wire: you should see AUTH commands before MAIL FROM. Missing AUTH commands are the smoking gun.
  2. Use port 587 with STARTTLS as your submission port. Port 587 is the RFC 6409 designated submission port for authenticated SMTP. Configure your app to connect on 587, negotiate STARTTLS, then authenticate, then send. Port 465 with implicit TLS is a legacy alternative that some providers still support (Gmail Workspace, for instance). Port 25 is for server-to-server relay only and should never be used for authenticated submission from applications. Most modern ISPs also block outbound port 25 for residential and non-mail-server networks.
  3. Verify your credentials against the relay server directly. Before touching your app code, prove the credentials work by connecting manually. Using openssl s_client -starttls smtp -connect smtp.example.com:587, or a tool like swaks, run the AUTH LOGIN handshake with your username and password. If the manual test also fails, the credentials are the problem: reset the password, generate a new API key, or check that the account is not disabled. If manual works but the app fails, your app config or library is misconfigured.
  4. Add your sending IP to the relay allowlist (self-hosted only). For Postfix, add the IP to mynetworks in main.cf and reload postfix. For Exim, update hosts_allow_relay. For self-hosted Exchange, add the IP to the receive connector Remote Network Settings. After the change, reload the mail service and retry the send. Only allowlist IPs you fully control and trust: allowlisting shared or dynamic IPs turns your server into an open relay that will be abused for spam within hours of discovery.
  5. Update the outbound server hostname if you migrated providers. Common configurations drift out of alignment after ESP changes or domain migrations. Confirm the outbound hostname in your app matches what your CURRENT provider documents, not tribal knowledge or an outdated wiki page. Providers occasionally deprecate old outbound hostnames without prominent warning. If your app has been sending for years without change, the hostname it uses might have been quietly retired and you are hitting a legacy endpoint that no longer accepts your credentials.
  6. Consider switching to a dedicated SMTP relay service. For applications that need reliable outbound delivery without infrastructure management, dedicated services (SendGrid, Mailgun, Amazon SES, Postmark) handle relay configuration, authentication, port setup, and TLS entirely. You call their API or SMTP endpoint with an API key, they handle everything downstream. This eliminates the whole category of 550 5.7.1 relaying-denied errors caused by self-hosted misconfiguration, and typically costs less than the developer time spent maintaining your own relay.

๐ŸŒ How each provider sends this exact code

Provider
Exact response
Likely cause
Postfix
550 5.7.1 <user@domain>: Relay access denied
IP not in mynetworks, no SMTP AUTH
Exchange 2016+
550 5.7.1 Client does not have permissions to send as this sender
Sender domain not in Accepted Domains
Sendmail
550 5.7.1 ... Relaying denied
Access DB blocking or no AUTH
Gmail SMTP relay
550 5.7.1 Invalid credentials for relay
Wrong app password or 2FA required

โš– How this code differs from adjacent ones

Code
Real meaning
Action
554 5.7.1
Permanent relay access denied variant
Same fix, deeper failure
454 4.7.1
Transient relay access denied
Retry after fixing AUTH
550 5.7.54
Unable to relay in non-accepted domain
Add domain to Exchange Accepted Domains

Prevention going forward

Once relaying-denied is fixed, keep it fixed with configuration discipline that catches drift before it produces outbound outages.

  • Document your outbound SMTP configuration in one authoritative place. When credentials rotate or provider settings change, apps break silently unless a single source of truth tells every service what to use. A wiki page, a config manager entry, or a secret store with clear naming beats tribal knowledge.
  • Rotate SMTP credentials on a schedule you control, not on emergency. Sudden rotation across dozens of apps causes 550 5.7.1 storms because updates lag deployments. Predictable rotation windows with staged rollouts eliminate the panic-fix pattern.
  • Prefer authenticated ESP submissions over self-hosted relay wherever operationally viable. Managed services handle the entire class of relay-configuration complexity that produces 550 5.7.1, at costs that typically undercut the labor to maintain your own relay.
  • Test outbound sends immediately after any infrastructure change. A new container image, a firewall rule update, or a security patch can shift outbound behavior in ways that only surface as 550 5.7.1 when the app next tries to send, often hours later.
  • Monitor authentication failure rates on your relay server. A spike in AUTH failures precedes 550 5.7.1 storms by minutes to hours, and gives you time to fix credentials or config before customers notice missing emails.

Frequently asked questions about 550 5.7.1

Is 550 5.7.1 relaying denied the same as the 550 5.7.1 I see from Gmail or Outlook?
No, and this is one of the most confusing aspects of SMTP status codes. Both use the same numeric code (5.7.1) because RFC 3463 uses it for the general policy-and-security failure class. But the CAUSE is completely different: relaying-denied 5.7.1 is a sender-side problem where your outbound relay refuses your request, while Gmail/Outlook 5.7.1 is a receiver-side problem where their inbound filter refuses your message. The diagnostic text tells you which: "relaying denied" or "relay access denied" points to your outbound relay, while wording like "IP blocked" or "authentication failed" at RCPT time points to the receiving server. Fix accordingly.
Why do I need SMTP AUTH? My app sent fine last week without it.
Something changed. Either your credentials expired, your outbound server updated its config to disallow unauthenticated relay, or you moved to a different sending IP that is no longer allowlisted. Modern relays never permit unauthenticated relay from the general internet because it makes them instant spam sources. If your app worked before without AUTH, you were either sending from an allowlisted IP that has since changed, or connected to an internal relay that had different rules. Whatever the previous config was, enable SMTP AUTH now: it is the only durable answer.
Should I use port 25, 465, or 587?
Port 587 with STARTTLS is the recommended default for authenticated SMTP submission per RFC 6409. Port 465 with implicit TLS is an older alternative that some providers still support (Gmail Workspace and iCloud, for instance). Port 25 is for server-to-server relay only: most providers refuse AUTH on port 25 and many ISPs block outbound port 25 entirely for residential and non-mail-server networks. If your app is on port 25 and getting 550 5.7.1, move to 587 and the issue will very likely resolve. If port 587 is filtered by your network, ask your infrastructure team to open it or use port 465 as a fallback.
Can I fix relaying denied without changing my sending code?
Sometimes. If the cause is a credentials rotation, updating credentials in your secret store without touching code is enough. If the cause is a missing IP allowlist entry, adding your IP to the relay mynetworks or receive connector is enough. If the cause is missing SMTP AUTH in the app itself, no: you need to change the code or the config, depending on whether AUTH is togglable in your library. The safest first move is always to reset credentials, verify the IP is allowlisted, and retry. If both check out, only then dig into the code.
What is the difference between "relaying denied" and "recipient address rejected"?
"Relaying denied" means your outbound server refused to accept the message for delivery: you never got past your own infrastructure. "Recipient address rejected" means your outbound successfully sent the message but the RECEIVING server refused it. The two happen at completely different points in the SMTP conversation and require different debugging. Relaying denied is fixed on your side by adjusting auth, IP, or config. Recipient address rejected requires investigating the receiver rules: authentication, reputation, or blocklist.
Should I switch to a dedicated SMTP service like SendGrid or Postmark?
For most applications, yes. Managed services abstract away the entire class of 550 5.7.1 relaying-denied errors: you get an API key, you call their endpoint, they handle authentication, delivery, retries, and reputation. This is typically cheaper than paying developer time to maintain a self-hosted relay, and dramatically more reliable at scale. Self-hosted relay only makes sense if you have specific compliance requirements (data residency, custom logging) that dedicated services cannot meet. For everyone else: switch, save the operational cost, sleep better.

Stop 550 5.7.1 bounces before they happen.

SMTPing catches invalid addresses, disposables, catch-all traps, role accounts and dead mailboxes before you send. Fewer bounces means less firefighting and a healthier sender reputation. 13 validation types, 25 free daily, no card required.

Try SMTPing free โ†’

About the Author

Alaa - SMTPedia author

Alaa ยท LinkedIn

Email infrastructure specialist with 8+ years of hands-on experience in SMTP, deliverability, and email verification. Iโ€™ve configured and troubleshot mail systems across Postfix, Exchange, and cloud relays, managed IP reputation and warmup campaigns, and built verification pipelines processing millions of addresses. My work spans DNS authentication (SPF, DKIM, DMARC, BIMI), bounce handling, blocklist monitoring, and compliance frameworks including CAN-SPAM and GDPR. I write every article on SMTPedia to give email professionals, developers, and marketers the accurate, RFC-grounded reference they need.


About SMTPedia

SMTPedia is an independent email industry reference covering SMTP, IMAP, POP3, email deliverability, marketing platforms, DNS authentication, and email verification. Every article is researched from official provider documentation, IETF RFCs, and industry best practices. Settings and configurations are verified quarterly.

We are cited as a source by ChatGPT, Microsoft Copilot, and thousands of email professionals worldwide. Learn more about our editorial process.