Facebook tracking pixel

MailGenius

Generate Spf Record

You've published an SPF record, checked that it begins with v=spf1, and watched a syntax validator return a reassuring result. Then a campaign reaches Gmail's spam folder anyway. The problem may not be the visible TXT string. It may be what happens when the receiving server expands every nested include, checks the envelope sender, evaluates alignment, and decides whether the policy can be processed at all.

To generate an SPF record safely, you need more than a syntactically valid line. You need an inventory of legitimate senders, a lookup-aware design, a controlled rollout, and a real-world test that shows how mailbox providers treat the message.

Why a Correct-Looking SPF Record Still Lands You in Spam

A marketing manager adds the email platform's recommended include, publishes the TXT record, and sends a test campaign. The platform reports that SPF is configured. Gmail still places the message in spam. Their first instinct is to add another provider, tighten the ending, or regenerate the record from scratch.

That approach misses the receiver's job. A mailbox provider doesn't merely read the record as a list. It evaluates the sender's IP against the domain's SPF policy, follows DNS-based mechanisms, checks whether the policy can be completed within the permitted limits, and considers the result alongside DKIM, DMARC, reputation, and message content.

Google's requirements make this operational rather than theoretical. Beginning February 1, 2024, all senders to personal Gmail accounts must implement at least SPF or DKIM. Organizations sending 5,000 or more messages per day to Gmail accounts must use SPF, DKIM, and DMARC, according to Google's sender requirements. SPF is now part of the baseline configuration many businesses need to maintain.

Practical rule: A generator can produce a valid-looking record. Your job is to prove that receivers can evaluate it and that every legitimate sending path is covered.

Start by understanding what SPF authenticates, not what recipients see in the From line. Then build from an actual sender inventory, calculate the expanded lookup chain, stage the policy, and test the finished email with the MailGenius inbox placement test. That workflow catches failures a green syntax check won't.

What an SPF Record Actually Checks

Sender Policy Framework authenticates the SMTP envelope sender, the domain used in the Return-Path or MAIL FROM during SMTP. A receiving server looks up that domain's SPF policy in DNS, compares the connecting IP with the mechanisms in the record, and decides whether that IP is allowed to send for that domain. That is the actual SPF check receivers perform.

An infographic explaining how SPF records verify the sender's IP address and domain authorization for email authentication.

The record itself is usually a TXT record that starts with v=spf1. After that, each mechanism tells the receiver how to evaluate authorization. ip4 and ip6 permit specific addresses or ranges with no extra DNS work. include tells the receiver to fetch another domain's SPF policy and test the sending IP against that policy too. That difference matters in production, because a record can look tidy in a generator and still become expensive to evaluate at the receiver.

A simple example looks like this:

v=spf1 ip4:192.0.2.0 ip4:192.0.2.1 include:examplesender.email -all

In that example, the two ip4 mechanisms authorize specific IPv4 addresses, include:examplesender.email delegates authorization to a third-party sender's SPF policy, and -all says every other source should fail. Replace those placeholders with the systems that send for your domain. For example, a Google Workspace sender would use include:_spf.google.com. A Mailchimp sender would use the SPF mechanism its own documentation specifies. Publishing a copied record without mapping it to real senders is how legitimate mail gets rejected, or how old vendors stay authorized long after they should be removed.

The ending qualifier also changes how receivers interpret gaps. ~all is useful during rollout because unlisted senders soft fail, which gives you room to test. -all is stricter and makes sense only after the sender inventory is complete and the record evaluates cleanly. Neither qualifier fixes missing senders, broken includes, or a policy that hits an evaluation error before the receiver reaches the end.

SPF is not the visible From identity

SPF can pass while the message still shows a different From domain to the recipient. That is why an SPF pass by itself does not prove the visible sender identity. The mailbox provider may see a valid envelope domain, but if that domain does not align with the visible From domain, DMARC can still fail, as Google explains in its Gmail sender guidance.

I see this misread often in header reviews. Someone finds spf=pass and assumes authentication is finished. The receiver may instead be dealing with a pass on the wrong domain, a DKIM issue, or a DMARC alignment failure. Generate SPF for the actual envelope-sender domain, then verify that it lines up with the From domain the recipient sees.

Building Your SPF Record From an Inventory of Senders

A valid SPF string can still fail at the receiver if it authorizes the wrong systems. The work starts with a sender inventory, because SPF is evaluated against the server that sent the message, not the platform your team assumes is sending it.

List every system that can send with your domain in the return path or envelope sender. That usually means the marketing platform, CRM, transactional mail service, helpdesk, website, billing app, recruiting tool, and any outbound sales system. Include low-volume flows too. Password resets, invoice mail, forwarded support replies, and niche SaaS notifications are exactly the messages that get missed, then fail when a receiver checks the sending path.

Your published record needs to authorize every legitimate sender for that domain. If the business uses several providers, authorizing only the best-known one leaves gaps. Those gaps are where correct-looking records break. Mail from the forgotten system fails SPF, and the message header review later shows a policy that looked tidy on paper but never matched the sender in production.

Choose mechanisms based on ownership and stability

For each sender, determine what you control. If a provider gives you stable IP ranges and maintains them clearly, ip4 or ip6 keeps the policy explicit. If the vendor runs shared infrastructure that changes over time, include is usually the right call, because the provider can update its own SPF policy without waiting for you to rewrite yours.

Mechanism DNS Lookups Used Best Use Case
ip4 None A stable, provider-maintained IPv4 address or range
ip6 None A stable, provider-maintained IPv6 address or range
include At least one, plus nested dependencies A third-party sender whose infrastructure changes
a One DNS-based evaluation A domain's A or AAAA records intentionally represent senders
mx DNS-based evaluation Mail exchangers are also legitimate outbound senders
ptr DNS-based evaluation Legacy, deprecated in RFC 7208

Publish one SPF policy for the domain. Do not split permissions across separate SPF TXT records for the CRM, helpdesk, and email platform. Receivers expect a single policy to evaluate, and multiple SPF records create ambiguity that often ends in permerror.

A practical build might authorize a fixed transactional sender with direct IP mechanisms, add the marketing platform through its maintained include, and end with ~all while testing. That is a policy shaped by the sender inventory, not by a generator output pasted in without checking what the receiver will need to evaluate.

Every extra vendor you keep has a cost. An old include is not harmless clutter. It widens authorization, makes troubleshooting slower, and can consume lookup budget through dependencies you do not see in the top-level record.

I remove inactive senders before publishing whenever possible. It keeps the record shorter, easier to reason about, and less likely to fail for reasons that only show up during receiver-side evaluation.

The 10-Lookup Limit Most Generators Ignore

Many SPF generators answer the visible question, “What TXT string should I paste?” They don't always answer the more important question, “What does the receiver have to look up after it follows every dependency?”

RFC 7208 requires SPF implementations to limit the total DNS lookups caused by mechanisms and modifiers to 10 during evaluation. The limit applies across mechanisms such as include, a, mx, ptr, exists, and redirect. If evaluation exceeds that budget, the receiver must return permerror, meaning the policy cannot be reliably evaluated. The receiver doesn't stop at the tenth lookup and grant a partial pass.

A record can therefore look short while being expensive to evaluate. Four visible include mechanisms may each point to policies containing more includes, which can point to still more DNS-based mechanisms. The text you publish is only the top layer. The receiver evaluates the expanded chain.

Count the expanded policy, not the spaces on the page

Use a recursive SPF evaluator or lookup expander that shows the complete dependency tree. Count DNS-querying mechanisms throughout the chain, and distinguish them from direct ip4 and ip6 mechanisms, which don't consume the same DNS lookup budget.

A five-step infographic explaining how AI generators reach a 10-lookup limit when processing user prompts.

When the count is too high, don't keep appending vendor recommendations. Remove obsolete services, consolidate overlapping infrastructure, and replace an include with fixed ranges only when those ranges are stable and someone owns their maintenance. Flattening a provider that changes addresses frequently creates a different failure, because your record becomes stale while appearing tidy.

Separate subdomains can also help. A marketing stream, transactional stream, and outbound stream can use different envelope domains, giving each subdomain its own SPF lookup budget. That design requires careful domain setup and alignment, but it can be safer than forcing every sending function into one crowded policy.

The ptr mechanism deserves particular caution. RFC 7208 places a separate constraint on PTR processing, and reverse DNS evaluation adds latency and reliability concerns. Avoid it unless there is a compelling, controlled reason to use it.

Publishing and Verifying Your Record the Safe Way

Publish one SPF TXT record for the correct envelope-sender domain, then start with ~all while you validate the sender inventory. This isn't an excuse to leave a permissive policy in place indefinitely. It's a controlled way to discover forgotten senders before a hard fail affects legitimate mail.

Screenshot from https://mailgenius.com

Send test messages from every legitimate source. Inspect the receiving headers, identify the evaluated envelope domain, and confirm that the expected IP or provider policy receives an SPF pass. A test from the marketing platform doesn't validate the CRM, helpdesk, or transactional service.

Microsoft recommends setting the SPF TXT-record TTL to at least 3,600 seconds to reduce DNS timeout risk, as described in its SPF configuration guidance. Your DNS provider may label the host as @, the root domain, or the domain name itself. The interface differs, but the principle doesn't: edit the existing SPF TXT record rather than creating another one.

Move from observation to enforcement

After testing, remove obsolete services and investigate any unexpected sender. Check the complete lookup expansion again after each vendor change. Once every legitimate source is covered and the policy evaluates cleanly, change ~all to -all.

A syntax checker can confirm that the text is shaped correctly. It can't tell you whether the message reaches the inbox, whether DKIM signs correctly, whether DMARC aligns, or whether the domain has a reputation problem. Use an SPF and DKIM checker for authentication details, then send a real test message through the finished workflow.

The final verification should happen in the mailbox ecosystem, not only in DNS. Run a free spam test at MailGenius to receive a scored report and see whether providers such as Gmail, Outlook, and Yahoo identify problems beyond the SPF string.

Retest after changing vendors, envelope domains, DKIM settings, or sending infrastructure. SPF is a maintained dependency, not a one-time certificate.

When SPF Fails Despite a Perfect Record

Forwarding is the failure that exposes the difference between a correct record and a successful delivery path. SPF checks the connecting server's IP against the original domain's envelope policy. When another service forwards the message, that forwarder's IP may not be authorized by the original sender, so a legitimate message can fail SPF, as explained in this forwarding and SPF overview.

Adding arbitrary forwarding-server IPs is usually the wrong repair. Forwarding infrastructure may be broad, change frequently, or sit outside your control. Instead, preserve identity with DKIM and DMARC alignment, and use forwarding-aware mechanisms such as ARC or Sender Rewriting Scheme where the receiving ecosystem supports them.

An infographic titled When SPF Fails explaining six common reasons why sunscreen application might not prevent sunburn.

Other failures are easier to isolate once you classify the symptom:

  • Multiple policies: Merge separate SPF TXT values into one policy for the domain.
  • Wrong envelope domain: Check the domain the receiver evaluated, not only the visible From address.
  • Misalignment: A passing SPF result can still fail DMARC when the authenticated domain doesn't align with the recipient-visible domain.
  • Stale includes: Remove providers that no longer send and recalculate the expanded chain.
  • Unverified paths: Test every application that sends, including low-volume transactional and support systems.
  • Reputation problems: If authentication passes but placement remains poor, check if your domain is blacklisted and review the wider message and sender signals.

Retest after every vendor change with a real spam test at MailGenius. That separates an SPF record defect from a forwarding limitation, an alignment issue, or a broader deliverability problem.


MailGenius tests SPF, DKIM, DMARC, blacklist status, message quality, and inbox placement signals across major mailbox providers, then returns prioritized fixes. Visit MailGenius, send a test message, and use the report to verify that your newly generated SPF record works beyond the DNS screen.

Free Email Spam Test:

Will your Email Land in the Spam Folder?

Send an email to the address below to see your Spam Score:
loading...
MailGenius users test over 1M emails per year! By using our Email Tester, you will agree to our Privacy Policy and Terms of Service. The sending email address will receive emails from MailGenius. All tests are hosted on public links.

Try MailGenius Today

Run a Free Email Deliverability Test - Send an Email to the Address Below, then Click “See Your Score”:

Free Email Spam Test:

Will your Email Land in the Spam Folder?

Send an email to the address below to see your Spam Score:
loading...
MailGenius users test over 1M emails per year! By using our Email Tester, you will agree to our Privacy Policy and Terms of Service. The sending email address will receive emails from MailGenius. All tests are hosted on public links.

Try MailGenius Today