By Arkay · Updated
How do you use the SPF and DMARC record generator?

Select the services that send mail for your domain, add any other sending IPs and set the policies. The generator then gives you the SPF TXT record, its DNS lookup count and the DMARC TXT record, with setup notes.
- Select each email sender you use: Google Workspace, Microsoft 365, Zoho, Mailchimp, SendGrid, Amazon SES or your own server.
- Enter any other sending IP addresses that send mail for your domain.
- Choose soft fail or hard fail. This sets the end of the SPF record to
~allor-all. - Set the DMARC policy, the report address and the percentage.
- Check the lookup count. It must stay at 10 or below.
- Copy the SPF record and the DMARC record for
_dmarc, then add both at your DNS host.
How does the SPF and DMARC record generator work?
The SPF record lists an include for each sender, plus mx and ip4 entries, and ends in ~all or -all. It counts DNS lookups against the limit of 10 set in RFC 7208. The DMARC record sets v=DMARC1, the policy, an optional rua report address and pct.
The page builds text in your browser. It does not look up a domain's live records, so it cannot see what is currently published.
Suppose you use Google Workspace and one sending server at 203.0.113.25, a documentation address, and you choose soft fail. The SPF record is:
v=spf1 ip4:203.0.113.25 include:_spf.google.com ~all
The generator counts the include as one lookup. The ip4 entry and ~all do not count. The page cannot see lookups made inside the included Google record, so leave room under the limit when you add several includes.
What do SPF, DKIM and DMARC each do?
SPF, DKIM and DMARC check mail in different ways, and they work together. SPF is defined in RFC 7208, DKIM in the DKIM standard and DMARC in the DMARC standard.
| Standard | Where it lives | What it does |
|---|---|---|
| SPF | A TXT record on your domain | Lists the servers that may send mail for your domain. |
| DKIM | A signature on each message, checked with a public key in DNS | Lets the signing domain claim some responsibility for a message. |
| DMARC | A TXT record at _dmarc, such as _dmarc.example.com | Tells receivers what to do with mail that fails, and where to send reports. |
What do Google and Yahoo require from bulk senders?
Google and Yahoo both require SPF or DKIM from senders, and bulk senders face extra rules. Since February 1, 2024, everyone sending to Gmail accounts must set up SPF or DKIM for their sending domains, as Google's sender requirements set out.
Senders of more than 5,000 messages a day to Gmail accounts must also set up DMARC, and its policy can be none. The From: domain must align with the SPF domain or the DKIM domain. Spam rates reported in Postmaster Tools must stay below 0.3%.
Yahoo began enforcing its sender standards in February 2024. All senders must implement SPF or DKIM at a minimum. Bulk senders must implement both SPF and DKIM, and publish a valid DMARC policy of at least p=none that passes, according to Yahoo's sender best practices.
The SPF and DMARC records this tool builds cover two of the DNS requirements above.
How do you write an SPF record for Google Workspace or Microsoft 365?
If you send only through Google Workspace, Google's SPF guide gives this record:
v=spf1 include:_spf.google.com ~all
Google recommends ~all in a Google Workspace SPF record.
For Microsoft 365, Microsoft's SPF guide gives this record:
v=spf1 include:spf.protection.outlook.com -all
Microsoft recommends -all for Microsoft 365 domains, because it also recommends DKIM and DMARC for the domain. For a domain that sends no email, Microsoft's SPF record is v=spf1 -all.
Google and Microsoft give different advice on the ending. Microsoft notes that DMARC treats both ~all and -all as SPF failures. It also says the DMARC policy is effectively ignored for ~all failures on messages that have no DKIM signatures.
A worked example shows how this works when one domain uses two senders. Suppose your mail goes through both Google Workspace and Microsoft 365. Put both senders in one record, with one include for each:
v=spf1 include:_spf.google.com include:spf.protection.outlook.com ~all
Read the record from left to right. The v=spf1 tag marks it as an SPF record. Each include names one sender, and the ~all at the end is the soft fail option, which is the choice in this example.
The generator counts each include as one lookup, so this record uses 2 of the 10 lookups at the top level. Google's and Microsoft's own records can add nested lookups, and the page cannot see them. If you also send through Mailchimp or SendGrid, add one more include for each, using the value that provider gives you, and check the count again.
How does the 10-lookup limit work?
An SPF check may make at most 10 DNS-querying terms, and only some terms count toward that limit. RFC 7208 says going over the limit returns a permerror. The table shows which terms count.
| Term | Counts toward the limit? |
|---|---|
| include | Yes |
| a | Yes |
| mx | Yes |
| ptr | Yes |
| exists | Yes |
| redirect modifier | Yes |
| all | No |
| ip4 | No |
| ip6 | No |
| exp modifier | No |
Microsoft's SPF guide warns that counting include statements is not enough. Having fewer than 10 include: statements does not guarantee fewer than 10 DNS lookups, because each include needs at least one lookup and nested includes add more. Read the lookup count rather than the number of includes.
Can a domain have more than one SPF record?
No. RFC 7208 says a domain must not have more than one SPF record, and a check that finds two returns permerror. Merge every sender into a single v=spf1 record.
An include: domain that does not resolve, or has no SPF record, also returns permerror, and messages might be rejected, according to Microsoft's SPF guide. Microsoft recommends sending bulk email from a subdomain with its own SPF record. Each subdomain has its own 10-lookup budget.
Which DMARC policy should you use, and how do you move from none to reject?

The UK's National Cyber Security Centre (NCSC) describes a staged rollout, and the steps below follow its timings. The p tag has three values, defined in the DMARC standard:
| Value | What it asks receivers to do |
|---|---|
| none | Take no specific action. |
| quarantine | Treat failing mail as suspicious. |
| reject | Reject failing mail. |
The first three steps start the rollout:
- Publish a TXT record at
_dmarcwithp=noneand a report address, such asv=DMARC1;p=none;rua=mailto:dmarc-reports@example.com. The UK NCSC says p=none does not affect the delivery of your email, and reports start arriving within 24 hours. - Stay at
p=nonefor about 6 to 8 weeks. The UK NCSC says many organisations move on from a policy of none after about that time. - Move to quarantine on a small percentage first, for example
v=DMARC1;p=quarantine;pct=50. The UK NCSC says starting small helps ensure any mistakes do not affect all email delivery.
The last three steps tighten the policy further.
- Raise
pctto 100 and keep monitoring reports for at least 4 weeks, as the UK NCSC advises. - Move to
p=reject. The UK NCSC says many organisations move from quarantine to reject after about 3 months, and that reject on all of your domains is the best way to prevent spoofing. - After moving to reject, monitor reports for at least 2 weeks. The UK NCSC says that if you have problems, you can revert to
p=quarantineuntil you are ready to progress again.
How do you read DMARC reports?
Aggregate reports are XML files, usually GZIP-compressed, and they go to your rua address. The DMARC standard says they include the SPF and DKIM results and whether each one was aligned. Without a rua address, receivers must not send aggregate reports. The default requested interval, set by the ri tag, is 86400 seconds, which is one day.
Check three things for each sending IP address: whether SPF passed, whether DKIM passed, and whether each result was aligned with the From: domain. Gmail requires that alignment for bulk senders, so a sender that fails it needs attention before you tighten the policy.
The UK NCSC says reports show where your mail comes from, for example by IP address, and whether it passed SPF and DKIM checks. Look for legitimate senders that fail. The NCSC says to add those sending systems to your SPF record, either by IP address or by reference to another SPF record.
How do you add SPF and DMARC records at your DNS host?
Create the TXT records at your domain registrar or DNS host, not in Google Workspace or Microsoft 365. Microsoft says the same for its SPF records.
In Cloudflare, open the DNS Records page, select Add record, choose TXT, complete the fields and select Save. Cloudflare's DNS guide describes the same steps.
Microsoft recommends a minimum TTL of 3600 seconds (one hour) on SPF TXT records to avoid DNS lookup timeouts.
More guides in Email Security.
Related guides
Frequently asked questions
- Do I need DMARC?
- Bulk senders to Gmail and Yahoo must publish DMARC. Gmail allows a policy of none, and Yahoo requires at least p=none that passes. For any domain, DMARC tells receivers what to do with failing mail, but without a rua address receivers send no aggregate reports.
- What is the difference between ~all and -all?
- -all is an explicit statement that the sender is not authorized. ~all is a weaker softfail, saying the host is probably not authorized. Google recommends ~all for Google Workspace, while Microsoft recommends -all for Microsoft 365.
- Why is my SPF record failing?
- Common causes are two SPF records on one domain, more than 10 DNS lookups, or an include: domain that does not resolve; each returns permerror. Microsoft also lists syntax errors: a trailing period after the domain, an equals sign instead of a colon after include, and a space after the colon.
- How long do DNS changes take to work?
- Google says it can take up to 48 hours for SPF authentication to start working. The generator does not look up live DNS, so check the published records after you save them.
Sources
- SPF records must be published in DNS as TXT records. (www.rfc-editor.org)
- DKIM lets the owner of a signing domain claim some responsibility for a message, checked w (www.rfc-editor.org)
- A DMARC record is a DNS TXT record published at the _dmarc subdomain, for example _dmarc.e (www.rfc-editor.org)
- Since February 1, 2024, everyone sending to Gmail accounts must set up SPF or DKIM for the (support.google.com)
- Yahoo began enforcing its sender standards in February 2024; all senders must implement SP (senders.yahooinc.com)
- Google's SPF record for a domain that sends only through Google Workspace is v=spf1 includ (knowledge.workspace.google.com)
- Microsoft's SPF record for a domain that sends only through Microsoft 365 is v=spf1 includ (learn.microsoft.com)
- In Cloudflare, you add a record from the DNS Records page: select Add record, choose the T (developers.cloudflare.com)