Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Google Workspace SMTP relay: 5.7.0 Email relay denied

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When a scanner or mail server sends through Google Workspace SMTP relay and Gmail refuses it, Gmail's SMTP errors list does not say "550 5.7.1 Relaying denied". It uses SMTP code 550, status 5.7.0 and the text "Email relay denied". One 5.7.0 line is "Email relay denied ip-address. Invalid credentials for relay for one of the domains in: domain-name (as obtained from HELO and (E)MAIL FROM)." The next sentence says the mail "is being sent from a domain or IP address which isn't registered in your Workspace account." A second 5.7.0 line, also shown with 550, is "Email relay denied ip-address. The sending email account has been temporarily suspended due to abuse."

A different row shows 550 with status 5.7.1 and the text "Invalid credentials for relay ip-address. The IP address you've registered in your Workspace SMTP Relay service doesn't match the domain of the account this email is being sent from." That is a mismatch between the registered address and the domain, not the same sentence as 5.7.0.

What the error means

Google's setup page says you can "set up the SMTP relay service to route outgoing mail through Google" for Microsoft Exchange or another SMTP server. The relay host is smtp-relay.gmail.com. "If you're using TLS encryption, configure your on-premise mail server to point to smtp-relay.gmail.com on port 587." Without TLS, the same page says ports 25, 465 or 587, and "you can't use SMTP authentication and must use IP address authentication."

The relay accepts mail only under the rule you configure. Allowed senders are one of three choices. "Only registered Apps users in my domains" requires a Google Workspace user in one of your domains. "Only addresses in my domains" allows an address that contains your primary domain, including subdomains, without that address being a Workspace user. "Any addresses (not recommended)" allows any address, "including addresses outside of your domain."

Authentication is one or both of "Only accept mail from the specified IP addresses" and "Require SMTP Authentication". SMTP authentication "verifies the connection by checking the user Google Workspace email address and password" and needs TLS. For an IP rule the setup page says "Use your own public IP address" and "keep the IP range as small as possible."

The 5.7.0 "isn't registered" text says the domain or IP address is not registered in the Workspace account. The 5.7.1 text is the registered IP not matching the domain the message claims. Gmail's error list, in its 5.7.1 row, gives this remedy for a domain that is not registered under the Workspace account or an empty envelope sender: "you must configure your email server either to use SMTP AUTH to identify the sending domain or to present one of your domain names in the HELO or EHLO command." Google's pages do not say which allowed-senders choice produces which error.

Likely causes

Cause What you see How to confirm
The public IP is not in the relay rule 550 5.7.0 Email relay denied, domain or IP not registered Compare the server's public address with the IP list in the relay setting
The domain in HELO or MAIL FROM is not registered in your Workspace account The 550 5.7.0 text "isn't registered in your Workspace account" Check the domain the server presents against the domains in your Workspace account, and read the allowed-senders option on the rule
The registered IP does not match the sending domain 550 5.7.1 Invalid credentials for relay The 5.7.1 row on Gmail's error list
The account is suspended for abuse 550 5.7.0 Email relay denied, "temporarily suspended due to abuse" That sentence, which points at the SMTP relay spam policy
The rule requires TLS and the server does not use it The setup page says "messages not sent over an encrypted TLS connection are rejected" Check whether the "Require TLS encryption" box is ticked, and whether the server uses TLS

Prove the cause before changing anything

All of these are read-only.

1. Copy the status code and the sentence. 5.7.0 "isn't registered" is a missing IP or domain. 5.7.1 "doesn't match the domain" is a mismatch. The suspended sentence is a different 5.7.0 line.

2. Read the relay rule in the Admin console. Google's setup page places it at Menu, Apps, Google Workspace, Gmail, Routing, then SMTP relay service. Note allowed senders, whether IP authentication, SMTP authentication, or both are on, and the IP entries. Google says you can change the setting only at the top-level organisation. A child organisational unit can view it.

3. Note the address the server actually connects from. Google says to use your own public IP address.

Fix

Match the rule to the way the server sends. There are two changes, made in this order: the Admin console rule, then the Postfix relayhost line. Google's setup page gives Postfix only the port 25 line below and gives no Postfix settings for the TLS path on port 587 or for SMTP authentication; for those paths, use your Postfix documentation. Google's Postfix section says "Don't change the default timeout settings for Postfix mail servers."

Change the relay rule in the Admin console

First, save the current rule by typing it into a text file named smtp-relay-rule-before.txt: the allowed-senders option, which authentication boxes are ticked (IP addresses, SMTP Authentication, or both), whether "Require TLS encryption" is ticked and the full list of IP entries. Keep a screenshot of the setting beside it.

Risk: the next step changes the SMTP relay service rule for the whole organisation. An IP range wider than the server needs accepts mail from other hosts. Google says a range may cover up to 65,536 addresses and recommends keeping it as small as possible. Choosing "Any addresses" "makes you more vulnerable to abuse".

On the SMTP relay service setting, tick "Only accept mail from the specified IP addresses", then click Add and enter the server's public address as an IP entry. Check the allowed-senders option against the sender addresses your server uses, using Google's description of what each option allows above, and change it only if it excludes them. Click Save.

To undo it: put the option, the authentication boxes and the IP list saved in smtp-relay-rule-before.txt back, which removes the entry you added.

Point Postfix at the relay

First, save the current configuration file, which holds the existing relayhost line:

sudo cp -p /etc/postfix/main.cf /etc/postfix/main.cf.before-gmail-relay

Risk: the next step makes Postfix send all outbound mail through smtp-relay.gmail.com on port 25 and reloads Postfix. A wrong host, or a relay rule that does not list this server, stops mail that previously left by another path.

Add this line to /etc/postfix/main.cf (Google's example path), replacing any existing relayhost line:

relayhost = smtp-relay.gmail.com:25

Then reload Postfix. Google writes the reload as # sudo postfix reload:

sudo postfix reload

To undo it: restore the saved file and reload again.

sudo cp -p /etc/postfix/main.cf.before-gmail-relay /etc/postfix/main.cf
sudo postfix reload

Example (illustrative): a Postfix server at 203.0.113.40 sends as alerts@example.com with no SMTP login. Gmail returns 550 5.7.0 Email relay denied and says the IP is not registered. The relay rule allows only registered users and has no IP entry. The administrator saves the Admin console settings and main.cf, adds 203.0.113.40, sets allowed senders to "Only addresses in my domains", sets relayhost = smtp-relay.gmail.com:25, and reloads Postfix. Restoring the saved Admin console settings and the saved main.cf returns the previous path.

Confirm the fix

  1. Send a test message, which is the last step in Google's Postfix section. Google's setup page says "Changes can take up to 24 hours but typically happen more quickly." Do not undo a change because the first test still fails.
  2. If the reply is now the 5.7.1 mismatch text, the registered IP and the domain in HELO or MAIL FROM still disagree. Gmail's 5.7.1 row says to use SMTP AUTH, or present one of your domain names in HELO or EHLO.
  3. If the reply is the suspended sentence, Gmail's list points to the SMTP relay spam policy for this row.

What to watch afterwards

  • A new public address has to be added. The old entry does not follow the server.
  • Google says SMTP relay "is intended for on-premise devices and applications" and "Don't use SMTP relay as a relay for email that originates from Gmail."
  • There is a 100-recipient limit per SMTP transaction for smtp-relay.gmail.com. A limit error is a different message and points at the relay error messages.

Risks and limits

  • Gmail's error list shows 5.7.0 for "Email relay denied". It does not show the wording "550 5.7.1 Relaying denied". The "isn't registered" row, the abuse-suspension row and the 5.7.1 "Invalid credentials for relay" row are each shown with SMTP code 550.
  • Google's Postfix section specifies port 25. Its TLS section specifies port 587 but gives no Postfix settings for it.
  • Google's setup page gives no command to print the current relayhost. Copy the line from the file it names.
  • Google's pages do not say which allowed-senders choice triggers which error.

Sources