# When a filtering appliance sits in front of Gmail, declare it as an inbound gateway

Published: 2026-11-10  
Author: Guanacos Tech (https://guanacostech.com)  
Canonical: https://guanacostech.com/blog/google-workspace-inbound-gateway-setup

> See which Admin console options to turn on when a relay or filtering appliance sits in front of Gmail, so SPF checks the real sender, not the relay.

**Short answer:** The inbound gateway setting tells Gmail that a relay or filtering appliance sits in front of your mailboxes. In the Admin console, open Apps, Google Workspace, Gmail, Spam, phishing and malware, add the relay's public IP addresses under Gateway IPs, and turn on Automatically detect external IP so SPF reads the original sender, not the relay.

Say a 20-person distributor buys an email security appliance, points the domain MX records at it, and the complaints start the next morning. Invoices from the freight forwarder land in spam. So do the bank statements. The mail filtered hardest comes from the two suppliers whose SPF and DMARC are set up properly. Nothing changed at the sending end. What changed is that every message now reaches Gmail from the same machine, the appliance, and Gmail is judging that machine instead of the sender.

This happens on any domain where something terminates SMTP before Google does: a filtering appliance, a hosting company relay, an archiver, an old on-premises server kept alive for one application. The repair is one setting in the Admin console, and it takes ten minutes once you know which options to touch. On inherited domains it is the first thing we check when a client tells us spam filtering got worse right after a security project.

## What Gmail sees when nothing is declared

Gmail uses the source IP address of a message to run SPF and to judge how suspicious the message looks. With no gateway declared, the source address is whatever machine opened the connection, which is your appliance. Three things follow from that.

- **SPF fails for the senders who did everything right.** The freight forwarder authorizes its own mail servers in its SPF record, not your appliance, so the check fails on arrival. A sender with no SPF record at all is unaffected, which is why the careful correspondents are the ones who break.
- **DMARC follows SPF down whenever DKIM does not survive.** If the appliance passes the message through untouched, the DKIM signature still verifies and DMARC can still pass on DKIM alone. Appliances that rewrite the subject line or paste a warning banner into the body break the signature, and then nothing passes.
- **Every sender shares one reputation.** Spam scoring sees one address sending everything, good and bad, so the newsletter nobody reads and the invoice everybody needs carry the same history.

The inbound gateway setting is how you tell Gmail that the appliance is part of your own plumbing rather than the sender. Gmail then skips SPF and DMARC for messages arriving from the addresses you list, and looks further back in the headers for the address that actually sent the mail.

## Where the setting lives, and what each option does

In the Admin console, open Apps, then Google Workspace, then Gmail, then Spam, phishing and malware. Select your top-level organizational unit, scroll to Inbound gateway and click Edit. You need the Gmail settings administrator privilege to see it at all. The path and the option names were checked on 10 November 2026, and Google moves things, so read the labels in front of you rather than trusting anyone's screenshot.

Gateway addresses have to be public. Private addresses are not supported in this setting, so a relay that lives on an internal network has to present a public address to Google or it cannot be declared here.

| Option | What it does | When we turn it on |
| --- | --- | --- |
| **Gateway IPs** | Lists the public addresses Gmail should treat as your own relay instead of as the sender. Gmail does not run SPF or DMARC checks on mail arriving from these addresses. | Always, and with every address the gateway can send from, not just the one in the setup email. |
| **Automatically detect external IP** | Gmail reads the `Received: from` entries and uses the first public address that is not in the gateway list as the source IP for SPF. | Always, when the gateway is a filtering service sitting in front of Gmail. |
| **Reject all mail not from gateway IPs** | Messages from senders other than the inbound gateway are rejected. | Only after the MX cutover is finished and verified, never during it. |
| **Require TLS for connections from the email gateways** | Connection attempts from gateways that do not use TLS are rejected. | Once you have confirmed the gateway offers TLS from every address it sends from. |
| **Message is spam if regexp matches** | Treats a message as spam when a header matches the expression you enter, for example `^X-spam-gw:`. | When the gateway tags what it has already judged and you want Gmail to honour that verdict. |
| **Disable Gmail spam evaluation on mail from this gateway** | Header values become the main method used to decide whether a message is spam. | Rarely, and only when you can show the gateway filters better than Gmail does. |

## The option that decides whether SPF still works

Automatic external IP detection is the one that earns its place. With it on, Gmail reads the `Received: from` entries in the headers and takes the first public address that is not in your gateway list as the source IP for SPF. Google documents the behaviour with an example: with 192.0.2.2 and 192.0.2.55 listed as gateways and a further address of 192.0.2.110 recorded in the headers, the option on gives a source IP of 192.0.2.110, and the option off gives 192.0.2.55.

There is a failure mode worth knowing before you rely on it. If Gmail parses all the `Received: from` entries and cannot identify an external public address, it reverts to the connecting address, even when that address is in your gateway list. Two practical consequences. List every address the gateway can send from, including the full range the vendor publishes, because one address you missed becomes the sender as far as Gmail is concerned. And confirm the gateway preserves the `Received` headers it was handed instead of stripping them, since those headers are the only record of where the message came from.

While you have the vendor on the phone about headers, ask about ARC too. Google's guidance on forwarding mail into Gmail recommends adding ARC headers to forwarded messages along with an `X-Forwarded-For` or `X-Forwarded-To` header, and the sender guidelines name inbound gateways among the cases where a forwarder should seal mail with ARC. A gateway that seals properly hands the next hop a record of the authentication result as it stood before the gateway touched the message. Our guide to [why forwarding breaks SPF](https://guanacostech.com/blog/email-forwarding-breaks-spf) covers what survives that trip and what does not.

Free tool

Decode the headers of a message that went to spam

Paste the raw headers and see the Received chain plus the SPF, DKIM and DMARC results, line by line.

[Analyze headers](https://guanacostech.com/header-analyzer)

## What else quietly stops working

**Allowlist entries for a gateway address do nothing.** When the same address sits in the Gateway IPs list and in an email allowlist, the allowlist entry does not affect delivery or spam filtering. With a relay in front of Google, you declare the relay as a gateway and put the source behind it on the [approved senders list](https://guanacostech.com/blog/google-workspace-whitelist-domain-allowlist-senders), never the relay itself.

**Internal mail can leave and come back.** Routing rules, group forwarding and user forwarding push a message out to the domain MX record, which is now the gateway, and then back in. That mail reaches Gmail from the gateway like everything else, and it explains internal messages that fail authentication with no outside sender involved.

**MTA-STS and TLS reporting have to know about it.** Anything that terminates SMTP for the domain belongs in the MTA-STS policy with a certificate matching its hostname. A policy listing only Google's mail servers fails the moment the MX record points elsewhere, and the reports are how you find out. We walk through that in [MTA-STS and TLS reporting on Google Workspace](https://guanacostech.com/blog/mta-sts-tls-rpt-google-workspace).

**Spoofing protection moves to the gateway.** This is the consequence people miss. Gmail is no longer running SPF or DMARC on mail from the gateway addresses, so rejecting a message that claims to come from your own domain is now the gateway's job. Confirm in writing that the gateway enforces your published DMARC policy before you assume anybody is.

## How we set this up on a client domain

1. Get the vendor's published sending ranges in writing and confirm every address is public. A vendor that hands you one address in a setup email almost always has more.
2. Point the MX records at the gateway and wait for the old record TTL to expire before you trust any test. Google notes that new MX records can take up to 72 hours to be recognized, so plan a window.
3. Enter the gateway addresses, turn on automatic external IP detection, and save. Leave the reject and TLS options off for now.
4. Send a test from an outside domain with a strict DMARC policy and read the `Authentication-Results` header on arrival. SPF should name the original sender's address, not the gateway's. If it names the gateway, either an address is missing from your list or the headers are being stripped. Our walkthrough on [reading headers to find why a message went to spam](https://guanacostech.com/blog/read-email-headers-to-find-why-it-went-to-spam) shows what a healthy result looks like.
5. Turn on Require TLS, test again, then turn on rejection of mail that does not come from the gateway, and test again. One change at a time, because both options reject mail outright and the damage is invisible from inside the domain.
6. Decide on the spam header rule last. Leave Gmail's own evaluation on unless the gateway's verdicts are measurably better, and write the expression against a header the gateway adds to every message.

Two of those steps reject mail when they are wrong, so we run the cutover in the morning. A mistake made on a Friday afternoon is a weekend of silently refused invoices.

## What we watch in the month after

A gateway is not configured once and forgotten. Vendors add addresses, certificates renew, and a routing rule added for one department starts a loop. For the first month we keep four things in view.

- The `Authentication-Results` header on a sample of inbound mail every week, looking for SPF results that still name the gateway.
- The spam folder and the admin quarantine for senders who used to arrive cleanly, which is also a good moment to decide who reviews that [quarantine](https://guanacostech.com/blog/google-workspace-email-quarantine-review) and how often.
- Your own [DMARC aggregate reports](https://guanacostech.com/blog/how-to-read-dmarc-aggregate-reports), where internal mail that loops out through the gateway and back shows up as rows you did not expect.
- The vendor's change notices, because a new sending range that never reaches your gateway list turns into a week of mysterious SPF failures.

## How Guanacos Tech helps

Most of the inbound gateways we meet were set up correctly for routing and never finished for authentication: the MX record points at the appliance, the addresses are in the console, and automatic external IP detection was left off, so every well-authenticated sender in the supply chain has been failing SPF for months. We audit the path, declare the gateway properly, verify it with real messages from outside, and leave the client the list of addresses to maintain. If something sits in front of your Gmail and you are not sure what Google is checking, that is ordinary work for us as [Google Workspace consultants](https://guanacostech.com/google-workspace), and a 30-minute call is enough to tell whether your gateway is declared or just connected.

## Sources

- [Set up an inbound mail gateway (Google Workspace Admin Help)](https://support.google.com/a/answer/60730?hl=en)
- [Set up MX records for Google Workspace (Google Workspace Admin Help)](https://support.google.com/a/answer/61158?hl=en)
- [Best practices for forwarding email to Gmail (Google Workspace Admin Help)](https://support.google.com/a/answer/175365?hl=en)
- [Email sender guidelines (Google Help)](https://support.google.com/mail/answer/81126?hl=en)
- [Allowlists, denylists, and approved senders (Google Workspace Admin Help)](https://support.google.com/a/answer/60752?hl=en)
- [RFC 7208: Sender Policy Framework (IETF)](https://www.rfc-editor.org/rfc/rfc7208)

## Frequently asked questions

### Does declaring an inbound gateway mean Gmail stops checking SPF?

Gmail stops running SPF and DMARC on mail arriving from the addresses you list, because it treats those as your own machines. With automatic external IP detection on, Gmail instead runs SPF against the first public address in the Received headers that is not on your gateway list, which is the original sender.

### Can I put a private IP address in the inbound gateway settings?

No. The setting does not support private addresses. A relay on an internal network has to present a public address to Google, otherwise it cannot be declared and Gmail keeps judging it as the sender.

### Should I also add the gateway address to the email allowlist?

No. When the same address is in the Gateway IPs list and in an email allowlist, the allowlist entry does not affect delivery or spam filtering. Allowlist the source behind the gateway if you need to, never the gateway itself.

---

Guanacos Tech is an independent consultancy with Google-certified engineers: email deliverability, Google Workspace and Google Cloud, in English and Spanish. Book a free 30-minute call: https://calendar.app.google/pq2seCCcch9U2GFV8
