← Back to Blog

Routing outgoing mail through an appliance: the outbound gateway, and the SPF record it needs

  • Gmail
  • Admin console
Routing outgoing mail through an appliance: the outbound gateway, and the SPF record it needs

Say a 30-person logistics company buys an email security service and the vendor sets up both directions at once: filtering in front of Gmail on the way in, scanning on the way out. Two days later the office manager calls. Quotes to a long-standing customer are bouncing, and a supplier says our mail now lands in junk. Nobody changed anything, and the Admin console looks healthy.

What changed is where the mail leaves from. With an outbound gateway in place, Google no longer delivers your mail to the recipient. It hands each message to a machine you or a vendor runs, and that machine does the delivering. Every check on the receiving end now points at that machine. If your DNS still says only Google sends for you, the receiving end is right to be suspicious.

We set these up, and we get called in to repair them. The setting takes two minutes. The DNS and message handling around it takes the week.

What changes the moment Google stops delivering your mail

Three things move at once, and only the first one is obvious.

  • The connecting IP address. The recipient's server sees the gateway, not Google, so SPF is evaluated against the gateway's address. Google's guidance is blunt: the SPF record must include the Google Workspace mail servers and the outbound gateway, or mail sent through the gateway is more likely to be marked as spam.
  • The DKIM signature is already on the message. Google signs before it hands over, so a valid signature can carry DMARC on its own even when SPF no longer matches the sending domain. That is also the fragile part: anything the gateway does to the message after signing invalidates it.
  • Delivery problems move house. Google's visibility ends where the gateway begins. A rejection from the recipient is now the gateway's event, and whether anyone sees it depends on its own notification settings.

Internal mail deserves its own decision. If messages between your own staff also leave through the appliance, you have put a third party in the middle of conversations that never needed to leave Google. We route internal mail straight through Google and send only external mail out.

Two ways to set it, and why we use the second one

Both live in the same place: Admin console, Apps, Google Workspace, Gmail, Routing, and you need the Gmail Settings administrator privilege to see them.

The Outbound gateway setting is the short road. Edit it, enter the hostname or IP address of the gateway, save. Google documents one hard limit on it: the setting can only be applied to the top-level organizational unit, not to individual organizational units.

The Routing setting is the longer road, the one Google recommends when you need more flexibility, and the one we use on nearly every project. You add the gateway as a host first, then build a rule that applies to outbound messages and sends them to that host. A rule can be scoped to an organizational unit, can carry its own transport requirements, and leaves room for a second rule that keeps internal mail inside Google.

Either way, Google says routing changes can take up to 24 hours to take effect, though they usually apply sooner. Plan the cutover for a Tuesday morning, not a Friday afternoon. Admin console paths and option labels here were checked on 11 November 2026.

This is not the SMTP relay service, and mixing them up costs a day

These two settings sit near each other in the Admin console and point in opposite directions. The SMTP relay service lets your own devices and applications send through Google: a warehouse scanner, a billing app, an on-premises server. Google states plainly that the relay is not for email that originates from Gmail. An outbound gateway is the reverse: mail that originates in Gmail leaves through something else.

So if what you need is a printer or an invoicing app sending as your domain, the relay is your setting, and the SMTP relay and Send mail as guide covers it. If an appliance has to inspect everything your staff sends, you want the gateway. Some vendors ask for both, which doubles the number of places a message can stop. If the same appliance also sits in front of your inbound mail, that is a separate setting with its own traps: see the inbound gateway write-up.

The SPF line the gateway needs

One record, not two. A domain publishes a single SPF TXT record, and the gateway goes inside it, next to Google.

v=spf1 include:_spf.google.com include:spf.gateway-vendor.example ~all

Use whatever the vendor publishes: an include: when they give you one, an ip4: or ip6: term when they give addresses. Then count. RFC 7208 section 4.6.4 caps SPF evaluation at 10 DNS-querying mechanisms, and include:_spf.google.com already consumes several. Adding a gateway include to a record that already carries a CRM and a marketing platform is how a domain ends up at PermError, which is not a pass for anybody. If you are anywhere near the limit, get under it before the gateway goes live, not after.

The footer that breaks every signature

This is the failure we see most often, and never the one the admin suspects. Many outbound appliances append a disclaimer, a confidentiality notice or an encryption banner to every message. Google signs with DKIM before the gateway receives the message, so the appliance is editing a body that has already been hashed. Google's own DKIM troubleshooting guidance names the case: an outbound gateway should not modify outgoing messages before they are sent, and some gateways add a footer to every outgoing message. There are two fixes, and the vendor has to pick one: configure the gateway so it leaves messages untouched, or move its content changes ahead of DKIM signing.

The recipient sees a DKIM result of fail or neutral with a body hash error. Combine that with SPF pointing at a gateway your DNS never mentioned, and a recipient enforcing p=reject is entitled to throw the message away. Pull the headers from one delivered and one rejected message and read them side by side. The Authentication-Results line says whether you have a body-hash problem or a DNS problem.

Look first at which IP address SPF was evaluated against: after a cutover it should be the gateway and nothing else. The header walkthrough reads those lines one at a time.

Lock the gateway down, or you are running an open relay

A machine that accepts mail and forwards it to the internet is valuable to people who are not you. Google's guidance: set up the outbound gateway to accept and forward email only from Google Workspace email server IP addresses, which keeps spammers from using it as an open email relay.

Google publishes the current ranges in the DNS TXT record _spf.google.com and the records it references, and notes that the addresses change often. It is complete for SPF purposes, so it is the right source for a mail allowlist, though it does not cover every range Google uses for other services. Read it again the day the gateway starts refusing Google.

dig +short TXT _spf.google.com

Transport, certificates and the test button

Mail leaving through a third party should leave encrypted. On a routing-based gateway, under Encryption (onward delivery only), tick Require secure transport (TLS) and Require CA signed certificate, which Google marks as recommended: Google then refuses to hand mail to a gateway whose certificate it does not trust. There is a Test TLS connection button for the host; use it before you save the rule. Forcing encryption to one named partner is a separate setting, Secure transport (TLS) compliance under Gmail, Compliance, which works per organizational unit against an address list. An MTA-STS policy, meanwhile, governs mail coming to you rather than mail leaving: the MTA-STS and TLS-RPT post covers that direction.

The order we set this up in

Each row has to be true before the next one starts. Skipping row two produces the week described at the top.

StepWhat we doWhat has to be true before moving on
1. Prove the gateway accepts usGive the vendor Google's published outbound ranges and accept only thoseA connection from Google's range is accepted and one from anywhere else is refused
2. Fix SPF firstAdd the gateway to the one existing SPF record, then recount the lookupsThe record resolves, still includes Google, and stays under 10 DNS-querying mechanisms
3. Decide what the gateway may touchTurn off disclaimers, banners and content rewriting, or move them ahead of signingA message through the gateway arrives with DKIM passing, not neutral
4. Build the route, scopedAdd the host, create the outbound rule, require TLS and a CA signed certificate, test the connectionThe test passes, and internal mail has its own rule that keeps it inside Google
5. Cut over on a quiet morningSave the rule and allow up to 24 hours for it to take effectMail to Gmail, to Outlook and to a real customer domain arrives, headers checked
6. Move monitoring to the new pathWatch DMARC aggregate reports for the gateway's address and read its rejection log dailyThe gateway appears in the reports as a named, passing source rather than an unknown one

What we watch in the month after

DMARC reports are where a gateway cutover shows its real result, because they come from the receiving end instead of your own logs. For the first two weeks we expect the gateway's address to appear as a new source, passing on DKIM and, once the record is right, on SPF. A source nobody can name is the signal to stop. Reading those reports takes ten minutes a week and is the only honest proof the change landed.

Then the quiet failures: a department whose mail still leaves directly because the rule was scoped too narrowly, and rejections the gateway absorbed without telling anyone, which is a conversation to have with the vendor before the cutover. Workspace sending limits still apply to the Gmail side of the path, and putting an appliance after Google does not raise them.

How Guanacos Tech helps

Most of the outbound gateways we inherit were finished for routing and never for authentication: the mail leaves through the appliance, the SPF record still lists only Google, and the disclaimer the compliance team asked for is invalidating every signature. We check the path end to end, fix the DNS before we touch the routing, get the gateway to stop editing messages, and stay on the DMARC reports for a month so you know the change worked. If an appliance is going in front of or behind your Gmail, our Google Workspace consultants can plan the cutover with you. A 30-minute call settles which routing method your setup needs and what your SPF record has to say.

Sources

Next step

Would you rather we did this for you?

Thirty minutes on Google Meet, free. We look at your domain or project with you, tell you what is wrong and what we would do first. If you can fix it yourself, we say so.

Book a 30-minute call or read about our Google Workspace consulting

Frequently asked questions

Does an outbound gateway break DMARC?

Not by itself. Google applies the DKIM signature before it hands the message over, so DMARC can pass on DKIM alignment even when SPF no longer matches. It breaks when the gateway edits the message, which invalidates the signature, or when the SPF record never mentions the gateway at all.

Can I apply an outbound gateway to one department only?

Not with the Outbound gateway setting, which Google limits to the top-level organizational unit. Add the gateway as a host and use a Routing rule instead, because a routing rule can be scoped to an organizational unit and leaves room for a second rule that keeps internal mail inside Google.

How long does the change take to apply?

Google says routing changes can take up to 24 hours to take effect, although they usually apply sooner. Treat that first day as a window where some mail still goes the old way and some goes the new way, and check message headers on both paths before you tell anyone the move is finished.