SPF Record Generator

Pick the services that send email for your domain and get one valid SPF TXT record, with the DNS lookup count checked for you.

Email services you use

include:_spf.google.com

include:spf.protection.outlook.com

include:zohomail.com

include:amazonses.com

include:sendgrid.net

include:mailgun.org

Values from each provider's setup documentation. Zoho accounts outside the US data centre use their own domain, such as zohomail.eu.

Your own servers

Allow the IP the domain's A record points to, e.g. a cPanel server that sends contact-form mail.

Allow the servers listed in your MX records. Not needed for Google or Microsoft if you selected them above.

Copy these from your newsletter, CRM or helpdesk provider's DNS instructions.

Everything else

Add this TXT record

Type
TXT
Host / Name
@ (your root domain)
Value
v=spf1 include:_spf.google.com ~all
  • Each include: can contain further lookups of its own, and they count towards the limit of 10. Check the finished record with an SPF checker after publishing.

DNS lookups counted here: 1 of 10 (not counting lookups inside include: records). Replace any existing v=spf1 record rather than adding a second one.

How SPF works, in one minute

When a server receives a message, it looks at the domain in the envelope sender (the Return-Path), fetches that domain's SPF record from DNS, and checks whether the sending server's IP address is on the list. Each item in the record is a mechanism: ip4 and ip6 list addresses directly, a and mx allow whatever your A or MX records point to, and include pulls in another domain's SPF list, which is how providers such as Google Workspace publish their ranges. The final all says what to do with everything not matched.

Worked example: Google Workspace plus a cPanel website

A small business sends staff mail through Google Workspace, and its WordPress site on shared hosting sends order and form notifications from the same domain. Select Google Workspace and turn on The domain's web server (a). The record becomes v=spf1 a include:_spf.google.com ~all. That costs 2 of the 10 lookups at the top level. If the site later moves to a different host, the a mechanism follows the new IP automatically, which is why it is often preferred to typing the IP for a website.

Staying under 10 lookups

Each marketing, CRM or helpdesk tool you connect usually asks for its own include, and many of them contain several more lookups inside. Remove services you no longer use first. Prefer ip4 ranges for your own fixed servers. If you still go over, ask the provider whether it can send from a subdomain such as mail.example.com with its own SPF record; that keeps the main record small. Avoid ptr: it is slow, unreliable and discouraged by the SPF standard.

Publishing and testing

Add the record as TXT at the root of the domain (often shown as @). In cPanel this is under Domains → Zone Editor → Manage → Add Record. After it has propagated, send a message to a Gmail address, open it, choose Show original, and check that SPF says PASS. Then set up DMARC so receivers know what to do with mail that fails, and read the DNS records guide if TXT and MX records are new to you.

Frequently Asked Questions

SPF (Sender Policy Framework) is a DNS TXT record that lists the servers allowed to send email for your domain. Receiving mail servers look it up and compare it with the server that delivered the message. A message from an unlisted server fails SPF, which makes it more likely to be rejected or sent to spam, especially when you also publish DMARC.
No. A domain must have exactly one TXT record that starts with v=spf1. If you publish two, receivers treat SPF as a permanent error and it fails for every message. When you add a new email service, merge its include into your existing record instead of adding a second one.
While checking SPF, a receiver may perform at most 10 DNS lookups. The mechanisms include, a, mx, ptr and exists, and the redirect modifier, each cost one, and lookups inside included records count too. Going over the limit makes SPF fail with a permanent error. ip4 and ip6 entries cost nothing, so listing fixed IP addresses is one way to stay under the limit.
~all (soft fail) asks receivers to accept but mark mail from unlisted servers, which is the safer choice while you are still finding every service that sends for you. -all (hard fail) says unlisted servers are not allowed at all. With DMARC in place, many domains keep ~all and let the DMARC policy decide what happens to failing mail.
In the DNS zone for your domain, at your registrar, your DNS host or in cPanel under Zone Editor. Create a TXT record with the host @ (the root domain) and paste the value. If an SPF record already exists, edit it rather than adding another. DNS changes usually appear within minutes to a few hours.
Not on its own. SPF checks the envelope sender (Return-Path), which can differ from the visible From address. DMARC connects the two by requiring SPF or DKIM to pass for a domain that aligns with the From address. That is why SPF, DKIM and DMARC are set up together.