Salesforce is one of the most widely deployed email-sending platforms in the world. It is not just a CRM. It is the engine behind millions of transactional notifications, marketing campaigns, automated workflows, and customer service replies every single day. When that email volume is tied to your domain and those messages arrive without proper authentication, the consequences go well beyond the spam folder. You are exposing your domain to spoofing, phishing attacks, and the kind of sender reputation damage that takes months to recover from.

The challenge with Salesforce email authentication is not that it is technically difficult. The challenge is that Salesforce’s default configuration is specifically designed to break SPF alignment, and most documentation stops at telling you to add an SPF record without explaining why that alone is insufficient to pass DMARC. Understanding the mechanics behind why Salesforce behaves this way, and what you need to do about it, is the difference between having authentication records that look correct and having authentication that actually works.

This guide covers the complete setup: SPF, DKIM, and DMARC across Salesforce Sales Cloud, Marketing Cloud, and Pardot (now Marketing Cloud Account Engagement). It explains how each protocol works in the context of Salesforce specifically, walks through step-by-step configuration, and covers the troubleshooting scenarios that trip up even experienced administrators.

What You’ll Need Before Starting

The Critical Thing Most Guides Miss: Salesforce’s SPF Alignment Problem

Before touching any DNS records, understand this:

By default, Salesforce routes bounces through its own infrastructure by setting the email’s Return-Path to a Salesforce-controlled address – something like sampleemail=salesforce.com__abc123@abc123.bnc.salesforce.com. This is intentional, for bounce management.

The problem: DMARC checks SPF alignment against the Return-Path domain, not the From address. Since that Return-Path belongs to Salesforce – not your domain – SPF will never be DMARC-aligned, even after you add include:_spf.salesforce.com to your record.

Adding Salesforce to your SPF record does not fix this.

The solution: DKIM is your primary DMARC alignment mechanism for Salesforce. DMARC only requires one of SPF or DKIM to align, so properly configured DKIM is all you need for compliance. You should still add Salesforce to your SPF record as a baseline, but DKIM does the heavy lifting.

Step 1: Set Up SPF for Salesforce

Even though SPF alignment won’t pass with default Salesforce settings, include it in your record for baseline authentication.

Check your existing SPF record first. Your domain can only have one SPF TXT record – a second record causes an immediate PermError. Look up your domain’s TXT records and find any record starting with v=spf1.

If one exists, add the Salesforce mechanism to it. If none exists, create a new TXT record on your root domain.

Salesforce SPF include:

include:_spf.salesforce.com

Example – Salesforce only:

v=spf1 include:_spf.salesforce.com ~all

Example – Salesforce + Google Workspace:

v=spf1 include:_spf.google.com include:_spf.salesforce.com ~all

Key rules:

  • One SPF record per domain – merge all senders into a single record
  • Keep total DNS lookups under 10 (each include: counts as one)
  • Use ~all (softfail) during setup; move to -all (hardfail) once verified

Want SPF alignment too? You can disable Bounce Management in Salesforce ( Setup → Email Administration → Deliverability → uncheck “Activate Bounce Management” ). This forces Salesforce to use your domain in the Return-Path, enabling SPF alignment. Trade-off: Salesforce stops auto-processing bounce notifications. Most organizations skip this and rely on DKIM alone, which is fully sufficient.

Step 2: Set Up DKIM for Salesforce Sales Cloud

DKIM is the protocol that actually gets you DMARC-compliant. Configure this before publishing your DMARC record.

Generate the DKIM Key

  • In Salesforce Setup, search DKIM Keys in the Quick Find box
  • Click Create New Key
  • Fill in the form:
  • RSA Key Size: Select 2048-bit (required by most inbox providers as of 2024)
  • Selector: Enter a unique name like sf-2025 – this becomes part of your DNS record name
  • Domain: Enter the domain in your Salesforce From address (e.g., yourcompany.com)
  • Domain Match Pattern: Enter your domain again
  • Click Save

Publish the DNS Records

Salesforce will generate two CNAME records . Copy them exactly – one character error breaks verification.

In your DNS provider, create two new records:

| Field | Value |

| — | — |

| Type | CNAME |

| Name | [selector]._domainkey.yourdomain.com |

| Value | The long CNAME target Salesforce provides |

Repeat for the second CNAME record.

Cloudflare users: Set both records to DNS Only (grey cloud). Proxied CNAME records will break DKIM lookups.

Wait for DNS propagation – typically 15 minutes to a few hours, up to 48 hours.

Activate the Key

Return to Setup → DKIM Keys , open your key, and click Activate . If it fails, DNS hasn’t propagated yet – wait and retry.

Verify It’s Working

Send a test email to Gmail, open the original headers, and look for:

DKIM-Signature: v=1; a=rsa-sha256; d=yourcompany.com; s=sf-2025; …

The d= should be your domain. If it is, DKIM is active and aligned.

Step 3: Set Up DKIM for Salesforce Marketing Cloud

Marketing Cloud handles DKIM differently depending on whether you have the Sender Authentication Package (SAP) .

Without SAP: Marketing Cloud uses Salesforce’s shared infrastructure. You cannot configure domain-level DKIM for your custom domain in this state. Emails sent via Marketing Cloud without SAP cannot be DMARC-aligned on your From domain.

With SAP: SAP provisions a custom subdomain (e.g., em.yourcompany.com) and handles DKIM signing under that subdomain automatically. DNS changes are made during SAP onboarding in coordination with Salesforce’s deliverability team. Since em.yourcompany.com shares the same organizational domain as yourcompany.com, DMARC relaxed alignment passes.

SAP is available for organizations sending 250,000+ emails/month. Contact your Salesforce account team to initiate onboarding.

Marketing Cloud DMARC alignment note: DMARC’s default relaxed alignment accepts subdomain matches – so DKIM signing for em.yourcompany.com aligns with a DMARC policy on yourcompany.com. No separate DMARC record needed for the subdomain.

Step 4: Set Up DKIM for Pardot (Marketing Cloud Account Engagement)

  • In Salesforce, navigate to Marketing Cloud Account Engagement → Settings → Domain Management
  • Click Add Domain and enter your sending domain
  • Pardot generates CNAME records – publish these in your DNS exactly as provided
  • Return to Domain Management and click Verify

Once verified, Pardot signs outgoing messages with DKIM automatically.

Step 5: Publish Your DMARC Record

With DKIM active, you’re ready for DMARC. Start with monitoring (p=none) before enforcing any policy.

Publish a TXT record at _dmarc.yourdomain.com (note the underscore – it’s a subdomain, not the root):

v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com; fo=1;

Core DMARC tags:

| Tag | What it does |

| — | — |

| p=none | Monitor only – no messages are blocked or filtered |

| p=quarantine | Failed messages go to spam |

| p=reject | Failed messages are rejected outright |

| rua= | Where to send aggregate reports (daily XML summaries) |

| ruf= | Where to send forensic reports (per-failure notifications) |

| pct= | Percentage of messages the policy applies to (default: 100) |

Only one DMARC record per domain is allowed.

Moving to Enforcement

Don’t rush this. The phased approach prevents blocking legitimate email from sources you forgot to authenticate.

Phase 1 – p=none (2–4 weeks minimum) Monitor your DMARC reports. Confirm all Salesforce traffic shows dkim=pass. Identify any other sending sources that are failing.

Phase 2 – p=quarantine at 25%

v=DMARC1; p=quarantine; pct=25; rua=mailto:dmarc@yourdomain.com;

Increase pct to 50, then 100 over the following weeks as you confirm no false positives.

Phase 3 – p=reject

v=DMARC1; p=reject; rua=mailto:dmarc@yourdomain.com; fo=1;

Full protection. Unauthenticated emails claiming to be from your domain are rejected.

Reading Your DMARC Reports: What to Look For

DMARC aggregate reports arrive daily from each major mail provider (Gmail, Yahoo, Microsoft). For each sending source, you’ll see whether SPF and DKIM passed, and whether they aligned with your From domain.

For Salesforce traffic with Bounce Management enabled, this is the expected result – and it is compliant:

<policy_evaluated>

<disposition>none</disposition>

<dkim>pass</dkim>

<spf>fail</spf>

</policy_evaluated>

spf=fail is expected – Salesforce’s Return-Path doesn’t align. dkim=pass is what carries DMARC compliance. If you see dkim=fail for Salesforce traffic, DKIM is not properly configured or hasn’t been activated. Do not move to enforcement until Salesforce shows consistent dkim=pass.

A DMARC reporting tool – dmarcian, Valimail, or the reporting tools at dmarcs.com – is strongly recommended over reading raw XML directly. These tools surface new unauthorized senders immediately, which is the real security value of DMARC.

Common Errors and Fixes

DMARC fails even though SPF passes for Salesforce Expected behavior with Bounce Management enabled. SPF passes at the mechanism level but doesn’t align with your From domain. Configure DKIM – that’s the fix.

DKIM key stuck in “Pending” in Salesforce DNS hasn’t propagated yet, or Cloudflare proxy is enabled on the CNAME records. Disable the proxy, wait, and retry activation.

SPF PermError – too many DNS lookups You’ve exceeded the 10-lookup limit. Audit your SPF record, remove unused include: entries, or replace nested includes with direct IP addresses using ip4:.

Multiple SPF records on the domain Delete all but one and merge all include: entries into a single record.

DMARC record not found Published at the wrong location. The record must be at _dmarc.yourdomain.com – missing the underscore (dmarc.yourdomain.com) or publishing on the root domain both cause lookup failures.

Quick Verification Checklist

SPF

  • One TXT record on the root domain, starting with v=spf1
  • include:_spf.salesforce.com is present
  • Total DNS lookups ≤ 10

DKIM

  • DKIM key created in Salesforce with 2048-bit key size
  • Both CNAME records published in DNS
  • Key shows Active in Salesforce (not Pending)
  • Test email headers show dkim=pass with d=yourdomain.com
  • DMARC reports confirm Salesforce traffic as dkim=pass

DMARC

  • TXT record at _dmarc.yourdomain.com
  • rua= points to a monitored inbox or reporting service
  • Reports being reviewed; all Salesforce sources show as compliant
  • Policy progression scheduled: none → quarantine → reject

Ongoing Maintenance

Rotate DKIM keys annually. Salesforce supports multiple active keys simultaneously, so rotation has zero downtime: create the new key, publish its DNS records, activate it, confirm it’s signing, then deactivate and remove the old key.

Audit SPF when adding new tools. Any new service that sends email from your domain – a support desk, a billing tool, a new marketing platform – needs to be added to SPF and have DKIM configured before it goes live.

Keep DMARC reports monitored. New unauthorized senders appear in reports the day they start. Catching spoofing campaigns early requires monitoring, not monthly check-ins.

*Ready to get started? Use our DMARC record generator, SPF checker, and report analyzer to set up, validate, and monitor your Salesforce authentication.*

Your emails are landing in spam. Or worse, they’re being rejected outright. You pull up the delivery logs and there it is: SPF PermError: too many DNS lookups . It looks like a minor technical hiccup. It is not. That single error means every email your domain sends is failing authentication, regardless of whether the message is legitimate or not. If your DMARC policy is set to quarantine or reject, the consequences compound fast.

This article walks through exactly what causes the SPF PermError, why the 10-lookup limit exists, how it interacts with your DMARC posture, and what you can actually do to fix it without breaking your email environment in the process.

Understanding the 10-Lookup Rule That Most Teams Hit Too Late

SPF (Sender Policy Framework) works by publishing a DNS TXT record that lists every server authorised to send email on behalf of your domain. When a receiving mail server checks an inbound message, it queries your DNS to verify the sending IP against that record. Simple enough, until you start chaining services together.

RFC 7208, the specification that governs SPF, sets a hard ceiling of 10 DNS mechanism lookups per SPF check. That limit covers the include , a , mx , ptr , and exists mechanisms, plus the redirect modifier. Critically, this is a cumulative count across the entire chain. If your SPF record includes _spf.google.com , that counts as one lookup. If Google’s own record includes further mechanisms, those count too. Nested includes add up faster than most administrators realise, and the validator on the receiving side stops counting at 10 and returns a PermError, full stop.

The mechanisms that do not count against this limit are all , ip4 , and ip6 , since they resolve directly to addresses without requiring additional DNS queries. That distinction matters a great deal when you start optimising.

Why the Limit Exists, and Why You Should Actually Respect It

The 10-lookup ceiling is not arbitrary. It exists to protect receiving mail servers from denial-of-service scenarios. A malicious actor could theoretically craft an SPF record that triggers hundreds of chained DNS lookups, consuming bandwidth and CPU on every validator that checks it. The limit prevents that amplification attack by design.

There is also a practical performance angle. Every DNS lookup during SPF evaluation adds latency. More lookups mean more round trips, more opportunities for timeout failures, and a higher chance that the evaluation never completes cleanly. Receiving servers have finite patience for authentication checks, and a record bloated with nested includes creates real delay in the delivery pipeline.

The second threshold in RFC 7208 is a maximum of 2 void lookups (meaning lookups that return no result or an error), and it is less discussed but equally dangerous. Hit that limit and you also get a PermError. Many organisations only discover this when a third-party service they included has quietly let their SPF record lapse.

How a Growing Tech Stack Quietly Pushes You Over the Limit

This is how it happens in practice. A company starts with a straightforward SPF record: Microsoft 365 gets an include, a CRM adds one, the transactional email service adds another. At that point the organisation is probably sitting around 5 or 6 lookups, comfortably within the limit.

Then growth happens. Marketing adds a new automation platform. Support adopts a helpdesk tool that also sends email. The outbound sales team integrates a sequencing tool. Each of these services requires an include statement. Each include triggers lookups of its own, and some of those services use providers that themselves chain to sub-records. Before anyone has audited the SPF record, the organisation has breezed past 10 lookups, and the first sign of trouble is a bounce report.

The uncomfortable truth is that most organisations hit this problem not through negligence but through exactly the kind of growth their business wants. The modern SaaS stack, where every tool sends email on behalf of your domain, is structurally in tension with SPF’s architecture. That tension needs to be managed deliberately.

The DMARC Connection: Why PermError Is Worse Than a Simple SPF Fail

An SPF fail means a sending server was not authorised. A PermError means something more fundamental: the SPF record itself could not be evaluated. DMARC treats these very differently.

When DMARC receives an SPF PermError, it interprets that as an SPF fail. If your DMARC policy is p=none , that may not affect immediate deliverability, but it will show up in your aggregate reports as a systematic authentication failure. If your policy is p=quarantine or p=reject , DMARC will act on that failure according to policy, and your legitimate emails will be quarantined or dropped.

That creates a painful situation: the more security-forward your DMARC posture, the more damage an SPF PermError causes. Organisations that have worked to move from p=none through to p=reject can find that a misconfigured SPF record effectively defeats their own enforcement. The receiving server has no basis on which to trust the message, and the DMARC record tells it exactly what to do with messages it cannot trust.

Given that Google and Yahoo mandated SPF and DKIM authentication for bulk senders starting February 2024, and Microsoft followed suit for its consumer platforms in May 2025, the stakes for getting this right have increased considerably. An SPF PermError is no longer a background noise problem that only affects a percentage of deliveries. It is a compliance failure that can trigger systematic rejection.

Diagnosing the Problem: Finding Out Where Your Lookups Are Going

Before you can fix an SPF PermError, you need an accurate count of where your lookups are being spent. The starting point is straightforward.

Run a DNS query against your domain’s TXT records:

dig TXT yourdomain.com +short

Locate the record starting with v=spf1 and look at every mechanism it contains. Count each include , a , mx , ptr , exists , and redirect . Then follow each include recursively and count the mechanisms in those records too. If you are not comfortable doing this manually, any reputable SPF checker tool will flatten the chain and give you a total lookup count alongside a breakdown of where each lookup originates.

Pay attention to a few common patterns that inflate counts unnecessarily. Duplicate includes are frequent, especially when multiple administrators have added records over time without auditing existing entries. Services that have been decommissioned but whose SPF records were never removed are another source of bloat, and they carry the added risk of becoming void lookups if the provider eventually removes the record. The ptr mechanism is a particular problem: RFC 7208 actively discourages its use due to performance concerns, and it costs a lookup while delivering limited benefit.

Practical Steps to Bring Your SPF Record Back Under Control

Audit and remove stale includes. Go through every include in your chain and verify that the service is still in active use and still requires email-sending authorisation from your domain. Services you no longer use have no place in your SPF record. This step alone frequently recovers two or three lookups.

Replace include statements with direct IP mechanisms. For services that send from a predictable, static IP range, there is no reason to use an include that triggers a DNS lookup. Replace them with ip4: or ip6: mechanisms pointing directly to the address or CIDR block. This is particularly effective for internal mail servers and hosting infrastructure where the IPs are under your control and unlikely to change frequently.

Consolidate redundant mechanisms. Multiple ip4: entries covering adjacent address ranges can often be combined into a single CIDR block. Similarly, if a vendor provides multiple SPF includes across different subdomains, check their documentation: many providers now offer a single consolidated include that replaces all the separate entries.

Remove the ptr mechanism entirely. If your record contains ptr or ptr:domain , remove it. RFC 7208 discourages its use, it costs a lookup, and modern SPF implementations provide no meaningful benefit from it.

Consider SPF flattening for complex environments. SPF flattening is the process of resolving all the DNS lookups in your chain to their underlying IP addresses and publishing those directly, replacing the nested include structure with a single flat record containing explicit ip4: and ip6: entries. This brings the lookup count to one (the primary record query itself). The drawback is maintenance: when a provider changes their sending IPs, your flattened record becomes stale immediately. Automated flattening tools monitor for these changes and update records dynamically, which is the more sustainable approach for organisations with complex sending environments.

Use SPF macros if your infrastructure supports it. For advanced deployments, SPF macros allow dynamic per-recipient evaluation without consuming lookup quota in the traditional sense. This requires more careful configuration but can be the right long-term architecture for organisations managing email at scale.

After the Fix: Validating and Monitoring

Fixing your SPF record is not a one-time exercise. As soon as you add a new SaaS tool, a new marketing platform, or a new transactional email provider, the lookup count goes up again. The organisations that avoid repeat occurrences are the ones that build a review step into their vendor onboarding process and maintain documentation of which services hold a slot in the SPF record.

After making changes, validate the updated record with an SPF checker that performs full recursive resolution. Confirm the total lookup count is at or below 10. Then send test emails through the services you modified and check the authentication headers ( Authentication-Results ) in the received messages to confirm SPF is passing.

Your DMARC aggregate reports are a secondary verification mechanism. Within a day or two of the fix, you should see the PermError rate drop to zero across the sources that were previously failing. If it does not, there is likely a secondary record or a subdomain sending configuration that has not been addressed.

One Record, One Policy, Consistent Results

A clean SPF record is not complicated infrastructure. It is a controlled list of authorised senders kept deliberately within a hard technical boundary. The organisations that run into repeated SPF PermErrors are usually those that treat the DNS record as an append-only log rather than a maintained policy document.

The good news is that the fix is always available. Unlike some authentication problems that require co-ordination with upstream providers, an SPF PermError is entirely within the domain owner’s control. Audit the record, remove what does not belong, replace dynamic lookups with static IPs where possible, and monitor the count every time the sending environment changes.

If you are working through SPF PermError issues and need help auditing your full authentication posture, including how SPF failures are interacting with your DMARC policy and DKIM alignment, the team at DMARCS can walk through your configuration and identify exactly where the chain is breaking down. Getting this right protects your deliverability, your domain reputation, and the trust your recipients place in every email your organisation sends.

To truly understand the Sender Policy Framework (SPF) , you must first understand the environment it was built to protect. When the Simple Mail Transfer Protocol (SMTP) was developed in the early 1980s, the internet was a small, academic, and highly trusted network. SMTP was designed simply to route messages efficiently from point A to point B. It was not designed to verify the identity of the person or machine sending the message.

Because of this architectural oversight, SMTP allows anyone to claim they are anyone else. Just as you can write a fake return address on a physical envelope and drop it in a public mailbox, a malicious actor can connect to a mail server and send an email claiming to be ceo@yourcompany.com.

This practice, known as email spoofing , became the foundation for global spam operations, targeted phishing campaigns, and devastating Business Email Compromise (BEC) attacks. As the internet exploded in commercial popularity, the lack of authentication became a critical vulnerability. The industry desperately needed a mechanism to verify that an email claiming to come from a specific domain was actually authorized by the true owner of that domain.

Enter SPF, standardized by the Internet Engineering Task Force (IETF) in RFC 7208. SPF provides a public, verifiable list of authorized sending servers for any given domain, turning the “honor system” of early email into a strict, cryptographic security checkpoint.

What is SPF?

SPF (Sender Policy Framework) is an open-standard email authentication protocol. It allows a domain owner to specify exactly which mail servers, IP addresses, or third-party hostnames are authorized to send email on behalf of their domain.

It operates entirely using the Domain Name System (DNS) . The domain owner publishes an SPF record , which is a specifically formatted line of text added to their DNS settings as a TXT record. When an email is sent across the internet, the receiving mail server looks up this DNS record and checks if the server attempting to deliver the email is on the approved list.

Why SPF is Non-Negotiable in Modern Business

In the modern email landscape, implementing SPF is no longer an optional “best practice”—it is a mandatory baseline requirement for any business that relies on digital communication.

  • Guarding Domain Reputation: Major Internet Service Providers (ISPs) and mailbox providers like Google, Microsoft, Yahoo, and Apple track the sending reputation of your domain. If spammers spoof your domain to send malicious content, your reputation drops. SPF stops unauthorized use, protecting your standing.
  • Strict Sender Requirements (2024 Updates): In early 2024, Google and Yahoo implemented strict new sender requirements aimed at bulk senders. If you send mail to Gmail or Yahoo accounts without a valid SPF record (and DKIM), your emails will be actively blocked or routed straight to the spam folder.
  • Foundation for Advanced Security (DMARC & BIMI): SPF is the foundational layer upon which DMARC (Domain-based Message Authentication, Reporting, and Conformance) and BIMI (Brand Indicators for Message Identification) are built. You cannot achieve full email security, nor can you display your brand logo in the inbox, without a perfectly configured SPF record.

How SPF Works

To understand how SPF validates an email, we have to look “under the hood” at how servers communicate during an SMTP transaction. This technical process is crucial for troubleshooting deliverability issues later.

When you send an email, there are actually two different “From” addresses involved in the transaction:

  • The Header “From” (Visible): This is the address that the human recipient sees in their email client (like Microsoft Outlook or Apple Mail). It is incredibly easy to forge and is *not* what SPF checks.
  • The Envelope “From” (Hidden): Also known as the Return-Path or mfrom (Mail From), this is the address used by the mail servers to route bounce messages and delivery errors. This is the exact address that SPF checks.

The Step-by-Step Validation Process

  • The Connection: The Sending Mail Transfer Agent (MTA) opens an SMTP connection with the Receiving MTA.
  • The Envelope Delivery: The Sending MTA issues the MAIL FROM: command, providing the hidden Envelope “From” address (e.g., MAIL FROM:<billing@example.com>).
  • The IP Capture: The Receiving MTA immediately records the public IP address of the Sending MTA that is currently connected to it.
  • The DNS Query: The Receiving MTA extracts the domain (example.com) from the Envelope “From” address. It then queries the DNS records of example.com, specifically looking for a TXT record that begins with the string v=spf1.
  • The Evaluation: Once found, the Receiving MTA parses the SPF record from left to right. It evaluates the captured IP address against the mechanisms and rules defined in the record.
  • The Verdict: Based on the evaluation, the Receiving MTA generates an official SPF result and applies that result to its internal spam-filtering algorithms to decide the fate of the message.

Anatomy of an SPF Record

An SPF record is a single, unbroken string of text. It consists of three primary components: the Version Tag, the Mechanisms, and the Qualifiers.

1. The Version Tag (v=spf1)

Every SPF record must begin with v=spf1. This explicitly identifies the TXT record to the parsing server as an SPF protocol record. If a record starts with v=spf2 (which was associated with the deprecated Sender ID framework) or lacks the prefix entirely, receiving servers will ignore it completely.

2. Mechanisms (The “Who”)

Mechanisms are the building blocks that define exactly who is authorized. The server reads these from left to right until it finds a match.

  • ip4 : Authorizes a specific IPv4 address or an IP network range using CIDR notation. This is highly efficient because it requires no additional DNS lookups. *(Example:* *ip4:192.168.0.1* *or* *ip4:10.0.0.0/24* *)*
  • ip6 : Authorizes a specific IPv6 address or network range. *(Example:* *ip6:2001:db8::/32* *)*
  • include : The most heavily used mechanism for third-party cloud services. It tells the receiving server to pause, look at the SPF record for another specified domain, and apply its rules as if they were your own. *(Example:* *include:_spf.google.com* *)*
  • a : Authorizes the IP address found in the domain’s primary “A” record (usually the IP address of your main website).
  • mx : Authorizes the IP addresses of the servers listed in the domain’s MX (Mail Exchange) records.
  • ptr *(DEPRECATED)* : Performs a reverse DNS lookup to see if the IP address resolves back to the domain. It is painfully slow, resource-heavy, and officially discouraged by RFC 7208. Do not use this under any circumstances.
  • exists : A highly advanced mechanism used to check if an A record exists for a given domain. It is almost exclusively used in complex enterprise environments utilizing dynamic SPF Macros.

3. Modifiers (The “Extras”)

Modifiers provide additional instructions but do not directly authorize IP addresses themselves.

  • redirect= : Tells the receiving server to ignore the current record entirely and go evaluate the SPF record found at another domain. This is incredibly useful if a parent company manages hundreds of subdomains and wants them all to point to one master policy. *(Example:* *v=spf1 redirect=_spf.masterdomain.com* *)*
  • exp= : Provides a custom explanation error message to the sender if their email is rejected. This is largely obsolete in modern email environments.

4. Qualifiers

The qualifier is the symbol placed at the very end of the record, directly attached to the all mechanism. It dictates the strictness of your policy for senders who fail the check.

| Qualifier | Name | Action | Security Posture |

| — | — | — | — |

| -all | Hard Fail | Reject the email. Only explicitly listed senders are authorized. | Maximum Security |

| ~all | Soft Fail | Accept the message but mark it as suspicious (sends to spam). | Moderate / Testing |

| ?all | Neutral | No policy regarding unlisted senders. Treats mail as if there is no SPF record. | Zero Security |

| +all | Pass | Authorizes every IP address on earth to send on your behalf. | Dangerously Insecure |

A Complete Real-World Example

Let’s dissect a typical corporate SPF record:

v=spf1 ip4:203.0.113.5 include:spf.protection.outlook.com include:servers.mcsv.net -all

  • v=spf1 : Declares this as an SPF record.
  • ip4:203.0.113.5 : Explicitly authorizes a specific on-premise private server to send mail.
  • include:spf.protection.outlook.com : Authorizes Microsoft 365 Exchange servers to send corporate email.
  • include:servers.mcsv.net : Authorizes Mailchimp servers to send marketing newsletters.
  • -all : Instructs receiving servers to flatly reject any email claiming to be from this domain if it did not originate from the IP, Microsoft, or Mailchimp.

Understanding SPF Evaluation Results

When an MTA evaluates an SPF record, the result is more granular than a simple “yes” or “no.” The server generates a specific status code that dictates the email’s fate.

  • Pass: The sender’s IP matched an authorized mechanism. The email safely moves to the next security checkpoint (like DKIM verification and content filtering).
  • Fail: The IP did not match any mechanism, and the record ended in -all. The email is typically rejected outright at the gateway and never reaches the user.
  • SoftFail: The IP did not match, and the record ended in ~all. The email is accepted but heavily penalized in internal spam scoring algorithms, usually resulting in spam folder placement.
  • Neutral: The IP did not match, and the record ended in ?all. No penalty or reward is applied based on SPF.
  • None: The receiving server could not find any valid SPF TXT record in the domain’s DNS.
  • TempError (Temporary Error): The receiving server encountered a temporary DNS timeout or network issue while trying to look up the SPF record. The server will usually return a 4xx SMTP error code and try again later.
  • PermError (Permanent Error): The SPF record exists but is fundamentally broken and cannot be interpreted. This happens due to syntax errors, multiple v=spf1 records, or exceeding lookup limits. A PermError is treated identically to a Fail.

The Technical Limits of SPF (Avoiding PermErrors)

SPF is an incredibly powerful protocol, but it was purposefully designed with strict limitations to prevent abuse and protect the global DNS infrastructure from being overwhelmed by infinite loops. Violating these limits is the number one cause of broken email authentication.

1. The 10-DNS-Lookup Limit

This is the most infamous and frequently violated rule in email administration. RFC 7208 dictates that evaluating an SPF record cannot require more than 10 DNS lookups .

  • Mechanisms that COUNT as a lookup: include, a, mx, ptr, exists, redirect.
  • Mechanisms that DO NOT count: ip4, ip6, all.

The “Nested Include” Trap:

The 10-lookup limit includes *recursive* lookups. If you add include:_spf.google.com to your record, that counts as one lookup. However, if Google’s SPF record contains three include statements of its own, evaluating Google’s record takes three more lookups. You have now consumed 4 of your 10 available lookups just by adding Google Workspace.

In a modern enterprise utilizing Google Workspace, Salesforce, Zendesk, Mailchimp, and a payroll tool, you will easily exceed 10 lookups without realizing it, instantly breaking your email authentication and generating a PermError.

2. The 255-Character String Limit

A single string within a DNS TXT record cannot technically exceed 255 characters. If your SPF record is very long due to multiple IP ranges, you cannot simply paste it as one giant block in some older DNS managers.

  • The Workaround: You must split the record into multiple contiguous strings enclosed in quotes within the same TXT record (e.g., “v=spf1 ip4:1.2.3.4…” ” include:_spf.google.com ~all”). The receiving server will seamlessly concatenate them back together.
  • Warning: Do not create multiple *separate* TXT records. Multiple strings inside one record are fine; multiple SPF records on one domain will cause a PermError.

3. The Void Lookup Limit

To prevent malicious actors from tying up DNS servers by pointing to domains that don’t exist, SPF limits “void” lookups (DNS queries that return an empty response or a timeout error) to a maximum of two. If your include statements point to defunct companies, legacy vendors, or dead domains, your entire record will fail.

Solving the 10-Lookup Limit

When large organizations hit the constraints of SPF, they cannot simply delete vendors. They must employ advanced architectural strategies.

Strategy 1: Subdomain Partitioning (The Best Practice)

The cleanest, most secure way to avoid the 10-lookup limit is to stop sending all mail from your root domain (@company.com). Instead, delegate specific software functions to dedicated subdomains.

Because DNS evaluates SPF strictly based on the exact domain found in the Return-Path, each subdomain gets its own independent 10-lookup limit , entirely solving the congestion problem.

  • Root Domain ( @company.com ): Used only for corporate, human-to-human email (Google Workspace/Microsoft 365).
  • Marketing ( @news.company.com ): Used for Mailchimp, Marketo, or HubSpot.
  • Support ( @help.company.com ): Used exclusively for Zendesk, Intercom, or Salesforce Service Cloud.
  • Transactional ( @receipts.company.com ): Used for SendGrid or Postmark.

Strategy 2: SPF Flattening

If subdomain partitioning is impossible due to branding guidelines, IT administrators turn to SPF Flattening. This is the process of resolving all include domains down to their base ip4 and ip6 addresses, and listing those raw IPs directly in the SPF record.

  • Before Flattening: v=spf1 include:salesforce.com include:zendesk.com ~all (Consumes 8+ lookups).
  • After Flattening: v=spf1 ip4:13.108.0.0/14 ip4:192.161.144.0/20 ~all (Consumes 0 lookups).
  • The Danger of Flattening: Cloud providers frequently change and expand their IP addresses. If Salesforce adds a new IP range and your flattened record isn’t updated, your Salesforce emails will suddenly fail SPF. Therefore, flattening must never be done manually; it requires automated vendor software that dynamically monitors and updates your DNS via API.

Strategy 3: SPF Macros (Dynamic SPF)

For massive enterprises or ISPs hosting thousands of domains, static SPF records are insufficient. SPF Macros allow the creation of dynamic records using variables.

  • %{i}: Represents the sender’s IP address.
  • %{s}: Represents the sender’s email address.
  • %{d}: Represents the sender’s domain.

When an IP connects, the receiving server reconstructs the query using the macro to ask a specific question to the enterprise DNS server, allowing for real-time, dynamic IP authorization based on internal threat intelligence.

Quick-Start Guides: Platform-Specific SPF Setup

If you use major cloud providers, setting up SPF requires specific syntax. Here are the exact include statements for the most popular platforms.

Google Workspace (G Suite)

If you use Gmail for your business, you only need one mechanism.

  • Record: v=spf1 include:_spf.google.com ~all

Microsoft 365 (Office 365)

Microsoft routes all outbound mail through a specific protection domain.

  • Record: v=spf1 include:spf.protection.outlook.com ~all

Mailchimp

Mailchimp recommends utilizing subdomains, but if you must use your root domain:

  • Record: v=spf1 include:servers.mcsv.net ~all

Shopify

To ensure order confirmations and receipts land in the inbox:

  • Record: v=spf1 include:shops.shopify.com ~all

*(Note: Always merge these into a single record. If you use both Google and Shopify, your record is:* *v=spf1 include:_spf.google.com include:shops.shopify.com ~all* *)*

The Great SPF Weakness: The Forwarding Problem

While SPF is an excellent foundational security measure, it has a fatal flaw: it breaks when emails are auto-forwarded.

Imagine Alice (alice@example.com) sends an email to Bob (bob@university.edu). Bob has set up his university account to automatically forward everything to his personal Gmail account (bob@gmail.com).

  • Alice’s server sends the message to the University. (SPF Passes, because Alice’s server is authorized by example.com).
  • The University server forwards the email to Gmail.
  • Gmail checks the Envelope “From” (which still says alice@example.com), but the IP address delivering the message is now the University’s server IP.
  • Gmail checks the SPF record for example.com. The University’s IP is not on Alice’s list.
  • Result: SPF Fails. Gmail marks Alice’s highly legitimate email as spam.

The Solution: SRS (Sender Rewriting Scheme)

To fix this, intermediate forwarding servers must implement SRS (Sender Rewriting Scheme) . SRS actively alters the Envelope “From” address during the forward. Instead of passing along alice@example.com, the University server rewrites the Envelope “From” to something like SRS0=abc=example.com=alice@university.edu.

When Gmail receives this, it checks the SPF record for university.edu. Because the University server is obviously authorized to send for its own domain, SPF passes.

*While SRS fixes the technical SPF failure, you cannot control whether a forwarding server uses SRS. This highlights exactly why SPF alone is not enough, bringing us to DKIM and DMARC.*

The Authentication Triad: SPF vs. DKIM vs. DMARC

SPF is powerful, but because it relies on the hidden Return-Path and routinely breaks during forwarding, it must be paired with DKIM and DMARC to achieve true security and deliverability.

DKIM (DomainKeys Identified Mail)

Where SPF validates the *server* using IP lists, DKIM validates the *content* using cryptography. The sending server attaches a digital “wax seal” (a cryptographic signature) to the email headers. The receiving server uses a public key found in the sender’s DNS to verify the signature.

  • Why it complements SPF: DKIM survives email forwarding. Even if the IP address changes during a forward (breaking SPF), the digital signature remains intact within the email body, proving to the final destination that the email is legitimate.

DMARC (Domain-based Message Authentication, Reporting, and Conformance)

DMARC is the master policy layer that unites SPF and DKIM. It does two critical things:

  • Enforces Alignment: SPF checks the Envelope “From,” which the user never sees. An attacker could buy a cheap domain (scam.com), set up a valid SPF record for it, and then change the visible Header “From” to ceo@yourcompany.com. SPF would technically pass, and the user would be fooled. DMARC stops this by requiring *Alignment* . For DMARC to pass, the domain in the hidden Envelope “From” (checked by SPF) must exactly match the domain in the visible Header “From”.
  • Sets the Rules: DMARC tells the receiving server exactly what to do if an email fails both SPF and DKIM (None, Quarantine, or Reject).

Frequently Asked Questions (FAQs)

Can I have multiple SPF records on one domain?

No. You can only have one TXT record that begins with v=spf1. If you have multiple services, you must combine their mechanisms into a single, unified string. Having multiple records will result in a PermError and authentication failure.

Does SPF check the “From” address I see in my email app?

No. SPF only checks the Envelope “From” (Return-Path) address, which is hidden in the email headers and used for routing bounces. This is why DMARC is necessary—to force the visible “From” address to align with the authenticated Envelope “From”.

How long does it take for a new SPF record to work?

Because SPF relies on DNS, changes are subject to DNS propagation. Depending on the TTL (Time to Live) set on your previous TXT record, it can take anywhere from 15 minutes to 48 hours for the global internet to recognize your new SPF policy.

What is the difference between ~all and -all ?

~all is a Soft Fail. It tells receiving servers that unlisted IPs are suspicious but should still be accepted (usually routed to spam). It is used during setup to prevent accidentally blocking legitimate mail. -all is a Hard Fail, instructing servers to strictly reject any unlisted IP. -all is the ultimate goal for maximum security.

Managing and Troubleshooting SPF

Discovering “Shadow Senders” via DMARC Reports

You should never transition your SPF record from a SoftFail (~all) to a HardFail (-all) blindly. You must implement DMARC in “report-only” mode (p=none) first.

Major mail providers (Google, Yahoo, Microsoft) will send you daily XML reports showing every single IP address that sent an email claiming to be from your domain. By analyzing these reports, you can discover forgotten internal servers, rogue marketing tools purchased by other departments, and active phishing campaigns. Once your reports prove that 100% of your legitimate mail is correctly passing SPF, you can safely lock down your domain with -all.

Common Troubleshooting Scenarios

Scenario 1: “My new marketing tool’s emails are going straight to spam.”

  • Cause: You likely forgot to add their specific include statement to your SPF record.
  • Fix: Edit your *existing* TXT record to add the new include. Do not create a second TXT record.

Scenario 2: “MxToolbox says I have a PermError: Too many lookups.”

  • Cause: Your combined include mechanisms are requiring more than 10 DNS lookups to fully resolve.
  • Fix: Audit your record. Remove legacy vendors you no longer use, replace nested includes with static ip4 ranges where possible, migrate high-volume senders to subdomains, or implement an automated dynamic SPF flattening service.

Scenario 3: “My SPF record is perfectly valid, but emails forwarded to Gmail are failing.”

  • Cause: This is the standard forwarding problem. The intermediate server is changing the IP address without rewriting the Envelope From via SRS.
  • Fix: Ensure you have DKIM fully configured and signing your outbound mail. Since DKIM survives forwarding, it will allow the email to pass the final DMARC check even when SPF inherently breaks.

Conclusion

The Sender Policy Framework is the absolute bedrock of modern email security. While the internet has evolved drastically since the inception of SMTP, the core need to verify digital identity remains paramount.

Mastering SPF requires far more than just pasting a line of text into your DNS panel. It requires a holistic understanding of your organization’s digital footprint, a deliberate strategy for managing DNS lookup limits, and a commitment to pairing SPF with DKIM and DMARC. By adhering to the technical specifications and architectural best practices outlined in this guide, you can eliminate domain spoofing, fiercely protect your brand’s reputation, and ensure that your legitimate business communications always find their way to the inbox.