# Why agent email lands in spam even when SPF and DKIM pass

> The fault usually lies in alignment between the From header and the signing domain, and an FDE can fix it with a dedicated sending subdomain.

Original: https://fdetimes.net/en/guides/agent-email-spam-spf-dkim-dmarc-alignment/

Since May 5, 2025, Outlook.com has been sending to the Junk folder mail from domains that send more than 5,000 messages a day without meeting SPF, DKIM and DMARC requirements.

Gmail and Yahoo already impose similar requirements on bulk senders. Microsoft has also warned that on a date it has yet to announce, failing mail will be rejected outright rather than merely filed as Junk.

For an FDE, this usually surfaces right after go-live. The agent is running: sending appointment confirmations, post-call follow-ups and payment reminders, all in the client's name. The sending platform's logs say "delivered", yet recipients see nothing. Then a ticket arrives: "all the bot's emails are going to spam."

This kind of failure lands on the FDE because it sits between three parties. The client's IT department owns DNS, the email platform owns the servers, and you own the deployment. Nobody sees the whole picture except whoever understands all three records and how they connect.

## Three records answer three different questions

SPF asks: is this server allowed to send mail for the domain in the Return-Path address? That is the address that receives bounced mail. It is usually set by the sending platform, and recipients almost never see it.

DKIM asks: is the digital signature on the message valid, and who signed it? The signing domain sits in the `d=` field of the `DKIM-Signature` header. Yahoo recommends DKIM keys of at least 1024 bits.

DMARC asks the most important question: does that pass belong to the domain the recipient actually sees in the From header?

RFC 9989, the DMARC specification published in May 2026 to replace RFC 7489, treats a message as passing DMARC when SPF or DKIM passes and the authenticated identifier matches the Author Domain, meaning the domain in From.

Google and Yahoo both state this requirement explicitly: the From domain must align with either the SPF domain or the DKIM domain.

**Key point:** Passing SPF and DKIM is not enough; the authenticated domain must match the domain the recipient sees.

## Why everything "passes" and mail still goes to spam

Take a hypothetical case to make it concrete. An agent sends mail as `support@client.com` through an email platform whose domain is `mail-platform.com`. Because nobody has configured the client's domain on the platform, messages go out with the platform's own Return-Path and DKIM signature. Open the original message in Gmail and you see roughly this:

```text
From: Support <support@client.com>
Return-Path: <bounce-8812@mail-platform.com>
DKIM-Signature: v=1; a=rsa-sha256; d=mail-platform.com; s=s1; ...

Authentication-Results:
  spf=pass smtp.mailfrom=mail-platform.com
  dkim=pass header.d=mail-platform.com
  dmarc=fail header.from=client.com
```

Read it line by line. SPF passes, but for `mail-platform.com`, not the From domain. DKIM passes, but the signer is also `mail-platform.com`. No identifier matches `client.com`, so DMARC fails, and for a bulk sender a DMARC failure is enough to get filtered.

A second variant is just as common: the platform uses the client's own Return-Path, but the client never added the platform to its SPF record. Gmail Help addresses this case directly: if a third-party sender is not in the SPF record, authentication can fail. Three lines of `Authentication-Results` are enough to tell which variant you are facing.

| Header field | Question it answers | Before the fix | After the fix |
|---|---|---|---|
| From | Which domain does the recipient see? | client.com | notify.client.com |
| Return-Path (SPF) | Is the server allowed to send? | mail-platform.com | bounce.notify.client.com |
| DKIM d= | Who signed the message? | mail-platform.com | notify.client.com |
| DMARC | Does any identifier match From? | fail | pass |

## Fix it with a dedicated subdomain for the agent

Resend, an email platform popular with developers and agent systems, recommends sending from one or more subdomains and lets you set a custom subdomain for the Return-Path. That is the right approach on most platforms: give the agent its own sending domain such as `notify.client.com`, sign DKIM with that same domain, then point the Return-Path to a child of it.

The DNS work usually comes down to three groups of records. The exact values are generated by the platform; the skeleton below only shows where each record belongs:

```text
; 1. DKIM: public key, supplied by the platform
s1._domainkey.notify.client.com  TXT  "v=DKIM1; k=rsa; p=MIIB..."

; 2. Custom Return-Path with its own SPF
bounce.notify.client.com  TXT  "v=spf1 include:<platform-domain> ~all"

; 3. DMARC for the subdomain, starting in monitoring mode
_dmarc.notify.client.com  TXT  "v=DMARC1; p=none; rua=mailto:dmarc@client.com"
```

Yahoo accepts a DMARC policy as weak as `p=none`, provided DMARC passes. That makes it a safe starting point: mail is not blocked by an overly strict policy, and the reports show you who is sending under the domain. Tighten the policy only once the reports are clean.

A subdomain also sidesteps a trap few people notice. RFC 7208 caps SPF at 10 DNS lookups; exceed it and the result is `permerror`, which amounts to a broken SPF record.

A company's main domain that already serves an office email suite, a CRM, a marketing tool and an invoicing system can easily be near that limit. One more `include` for the agent could break SPF for all of the company's mail, including the CEO's.

## Step by step at the client site

Start with diagnosis and leave DNS alone. Send a test message to a Gmail inbox, open the original, and copy the three domains for From, Return-Path and DKIM `d=` into the ticket, along with the three spf, dkim and dmarc results.

Next, agree with the client on the agent's sending domain. Propose a subdomain and explain it to IT in one sentence: if the agent misbehaves, the reputation of their main domain is not dragged down with it.

Then verify the subdomain on the email platform, enable the custom Return-Path, and send the client's IT team exactly the list of records the platform generates. Do not retype them by hand: a single wrong character in a DKIM key makes mail fail without a clear error.

Once DNS has updated, send another test message and accept the result only when all three lines pass. Finally, switch the From header in the agent's configuration to the new subdomain. This is the step most often forgotten, because it lives in your code rather than in DNS.

## Common mistakes

The first mistake is stopping when SPF and DKIM pass without checking which domain passed. The second is adding an `include` to the main domain's SPF record without counting DNS lookups. The third is setting DMARC to `p=reject` on day one, which also blocks legitimate mail flows nobody has listed yet.

The fourth is assuming that once authentication is in place, mail is certain to reach the inbox. Authentication is only the entry ticket. Google asks senders to keep their spam rate from reaching 0.30%, and Yahoo requires it to stay below 0.3% along with one-click unsubscribe for marketing mail. An agent that fires off follow-ups that recipients mark as spam can still push the whole subdomain into the filters.

## A skill worth putting on a CV

When reading FDE job ads, look for products whose agents send email, make calls or send messages on a client's behalf: that work will touch the client's DNS. On a CV, rather than "familiar with SPF/DKIM", describe a specific incident: DMARC failed because no identifier matched From, you moved sending to a dedicated subdomain, and here is what happened.

Before an interview, practice reading three lines of `Authentication-Results` and explaining them to someone non-technical.

The more work agents take over from people, the more mail they send in other people's names. The FDE who can tell whether that mail is "really from the client" will be the first person called when the bot goes quiet and nobody knows why.

**Try this week:**

- Send a test email from your agent or application to a Gmail inbox, open the original (Show original) and note the domains for From, Return-Path and DKIM d=.
- Count the DNS lookups in the SPF record of a client's main domain (include, a, mx, redirect, nested ones included) and see how far it is from the limit of 10.
- Write a one-page DNS checklist for a client covering the DKIM, Return-Path and DMARC p=none records for the agent's sending subdomain.

## Sources

- [Email sender guidelines - Gmail Help](https://support.google.com/a/answer/81126?hl=en-GB)

- [Sender Best Practices | Sender Hub](https://senders.yahooinc.com/best-practices)

- [Strengthening Email Ecosystem: Outlook's New Requirements for High‐Volume Senders](https://techcommunity.microsoft.com/blog/microsoftdefenderforoffice365blog/strengthening-email-ecosystem-outlook%E2%80%99s-new-requirements-for-high%E2%80%90volume-senders/4399730)

- [RFC 9989: Domain-Based Message Authentication, Reporting, and Conformance (DMARC)](https://www.rfc-editor.org/info/rfc9989)

- [Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1 (RFC 7208)](https://www.rfc-editor.org/rfc/rfc7208)

- [Verified Domains](https://resend.com/docs/dashboard/domains/introduction)
