SPF Record Generator Calculator

Build an SPF policy for your domain. Add senders, includes, and failover choices easily here. Get a ready record, checks, and export tools instantly.

Generator Inputs

Used for export context and guidance.
Applied to mechanisms (not modifiers).
Most domains start with ~all, then move to -all.
Authorizes A/AAAA of the given host.
Authorizes IPs of MX targets.
Comma-separated. Each include costs a DNS lookup.
Comma-separated IPv4 or CIDR.
Comma-separated IPv6 or CIDR.
Delegates policy to another domain.
Advanced. Requires a DNS design plan.
Discouraged. Often slow and fragile.
Optional explanation TXT at exp domain.
Lookup limit guidance Length checks Safety warnings

Example Data Table

Sample inputs and outputs for common mail platforms.
Scenario Inputs (summary) Generated SPF (example)
Workspace + Web App include: _spf.google.com; ip4: 198.51.100.0/24; ~all v=spf1 include:_spf.google.com ip4:198.51.100.0/24 ~all
Microsoft 365 rollout include: spf.protection.outlook.com; a; mx; ~all v=spf1 include:spf.protection.outlook.com a mx ~all
Strict enforcement a:mail.example.com; ip6:2001:db8::/32; -all v=spf1 a:mail.example.com ip6:2001:db8::/32 -all
Examples are illustrative. Always verify your real senders and lookup count.

Formula Used

The generator builds a policy string using this structure:

v=spf1 [qual]include:domain [qual]a[:domain] [qual]mx[:domain] [qual]ip4:cidr [qual]ip6:cidr [qual]exists:domain [qual]ptr[:domain] [all_qual]all [redirect=domain] [exp=domain]
  • qual is one of +, -, ~, ?.
  • all ends evaluation and defines default outcome.
  • DNS-lookup estimate counts a, mx, include, exists, ptr, and redirect.
  • Receivers commonly enforce a ~10 DNS-lookup limit for SPF evaluation.

How to Use This Calculator

  1. Enter your domain and choose a safe all qualifier (start with ~all).
  2. Add sender sources: include domains, ip4/ip6 ranges, plus optional a and mx.
  3. Use advanced options only if needed: redirect delegates policy; exists and ptr require careful design.
  4. Generate the record and review warnings for lookup and length limits.
  5. Publish the output as a DNS TXT record, then test mail flow before enforcing -all.

SPF as an identity control

SPF aligns envelope sender domains with approved outbound infrastructure. When receivers evaluate a message, they compare the sending IP against mechanisms like include, a, mx, ip4, and ip6. A tight policy reduces spoofing and supports mailbox provider reputation scoring across large volumes.

Mechanism selection and measurable impact

Static IP ranges (ip4/ip6) provide deterministic outcomes and do not add DNS lookups. By contrast, a, mx, and include require DNS queries during evaluation. This calculator displays an estimated lookup count to help maintain reliability, especially when using multiple email platforms simultaneously.

Lookup budget management

Many evaluators enforce a practical maximum of 10 DNS lookups per SPF check. Exceeding that threshold can yield a permanent error, which may break authentication for valid senders. Consolidating includes, removing unused mechanisms, and preferring direct IP authorization can keep the policy within budget.

Policy outcomes and rollout strategy

The all mechanism defines the default result. Softfail (~all) is commonly used during rollout because it signals suspicion without immediate rejection. After monitoring for several days and confirming every sender is covered, switching to fail (-all) strengthens enforcement and reduces abuse opportunities.

Record length and operational constraints

TXT strings often have a 255-character segment limit at the DNS layer, even if providers display longer records by splitting segments. Long policies can be brittle during migrations. Keeping records compact, avoiding ptr, and limiting optional modifiers improves cross-provider compatibility and simplifies change control.

Verification and ecosystem alignment

SPF works best alongside DKIM and DMARC. DKIM confirms message integrity, while DMARC uses SPF and DKIM alignment to decide enforcement. Use the exports to document decisions: store the SPF record, lookup estimate, and warnings as part of your security baseline and audit evidence.

FAQs

What does the DNS lookup estimate represent?

It approximates how many DNS queries evaluators may perform for include, a, mx, exists, ptr, and redirect. Keeping this near or under 10 improves reliability and reduces the chance of SPF PermError outcomes.

Should I start with ~all or -all?

Start with ~all to observe authentication results without hard blocking. After you confirm every sender is authorized and logs look clean, move to -all to enforce stricter protection.

Why is ptr discouraged?

PTR checks depend on reverse DNS and often trigger slow or inconsistent lookups. They can raise evaluation cost and may reduce deliverability. Prefer ip4/ip6 and well-scoped includes instead.

When should I use redirect?

Use redirect when one domain should fully inherit another domain’s SPF policy. It is best for centralized management. Avoid mixing redirect with heavy include chains, as it can increase lookup usage.

What is the EXP modifier used for?

EXP points to a TXT record containing an explanation string for failures. It is rarely needed, but it can help internal troubleshooting. It does not replace DMARC reporting and should be used carefully.

Does SPF protect the From header?

Not directly. SPF validates the envelope sender domain. DMARC is designed to align SPF and DKIM with the visible From domain. For user-facing spoofing resistance, deploy DMARC with monitoring and enforcement.

Operational Guidance

  • Rollout path: ~all → monitor → -all.
  • Avoid: +all unless for testing only.
  • Keep lookups low: fewer include entries.
  • Pair with: DKIM + DMARC for stronger protection.

Export Columns

CSV export includes domain, SPF record, lookup estimate, and any warnings. PDF includes a clean printable report.

Related Calculators

email header analyzerdmarc policy checkerdomain spoofing testspf flattening tooldmarc record generatordkim key generatorsmtp auth testeremail reputation checkermail spoof testemail authentication tester

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.