SPF Record Builder

SPF, Sender Policy Framework, tells receiving mail servers which servers are allowed to send email for your domain. Pick the servers that send your mail, choose how strictly receivers should treat mail from other servers, and the builder gives you a valid SPF record to add as a TXT record. The record updates as you type.

Your domain and senders

Your own mail servers

Include other senders

IP addresses that send your mail

How strict should receivers be?

Your SPF record

—
Record length—
DNS lookups used—
Mechanisms—
All qualifier—

Pick your senders to build the record.

Add this as a TXT record at your domain.

What Is an SPF Record?

SPF, Sender Policy Framework, is a DNS record that lists the servers allowed to send email for a domain. When a mail server receives a message claiming to be from your domain, it looks up your SPF record and checks whether the sending server is on the list. If it is, the message passes. If it is not, the receiver knows the message may be forged and can reject it or send it to spam, depending on the qualifier at the end of the record. Without SPF, anyone can send mail that claims to come from your domain, which is how most phishing and spoofing works.

How SPF Works

An SPF record is a single TXT record published in your domain DNS. It always starts with v=spf1 and ends with an all mechanism that says what to do with mail from servers not listed. The mechanisms in between name your senders: a means the server at your domain address record, mx means your mail servers, include: pulls in another domain SPF record, such as your email provider, and ip4: and ip6: name specific addresses or ranges. Every include, a, and mx causes a DNS lookup, and the SPF standard allows at most 10 lookups per check — go over that and receivers may stop checking and treat the result as an error. IP addresses do not use lookups, so they are a cheap way to add a sender. A single TXT string is also limited to 255 characters, so a record with many includes can run out of room.

Worked Example

Example: a domain that sends mail from its own mail servers and from Google Workspace. Tick a and mx, put _spf.google.com in the first include box, and choose -all. The builder produces v=spf1 a mx include:_spf.google.com -all. That record is 45 characters long and uses 3 DNS lookups: one for a, one for mx, and one for the include. A receiver checks the sending server against your address record, your mail servers, and Google SPF record in turn. Mail from any of those passes, and mail from anywhere else fails the check and is rejected. Add a second include, such as mail.example.com, plus an IPv4 address 203.0.113.5, and the record becomes v=spf1 a mx include:_spf.google.com include:mail.example.com ip4:203.0.113.5 -all, which uses 4 lookups — a, mx, and the two includes, while the IP address costs no lookup.

Common Mistakes

Publishing a record ending in +all. The +all qualifier tells receivers that every server on the internet may send mail as your domain. It defeats the whole point of SPF and invites spoofing. Use -all once you are sure your sender list is complete, and ~all only while you are testing.

Going over the 10 DNS lookup limit. Each include, a, and mx costs one lookup, and includes can hide more lookups inside them — Google SPF record, for example, contains further includes of its own. Keep the count low, and prefer ip4 and ip6 entries, which cost no lookups, when you know the exact sending addresses.

Publishing two SPF records. A domain must have exactly one SPF record. Two TXT records starting with v=spf1 make the check fail, because receivers cannot tell which one is correct. Merge all your senders into a single record instead.

Forgetting a sender. Every service that sends mail as your domain needs to be in the record: your mail host, your website contact forms, your newsletter tool, and your invoicing app. Leave one out and its mail starts failing SPF checks and landing in spam.

Putting the record on the wrong host. The TXT record belongs at the domain itself, not at a subdomain such as mail or www, unless that subdomain sends its own mail. A record on the wrong host is never found, and the domain looks as if it has no SPF at all.

Related Tools

Set the policy that uses your SPF record with the DMARC Record Builder, convert times across zones with the Time Zone Converter, count down to a launch or deadline with the Countdown Timer, work out a percentage of any number with the Percentage Calculator, and add or subtract days from any date with the Date Calculator.

Frequently Asked Questions

What is an SPF record?

An SPF record is a TXT record in your domain DNS that lists the servers allowed to send email for your domain. Receiving mail servers check it to tell real mail from forged mail. A domain with no SPF record lets anyone send mail that claims to come from it.

What does -all mean, and why is it recommended?

The -all qualifier at the end of the record tells receivers to fail mail from any server not listed in the record. It is the strictest option and the one that stops spoofing. The softer options are ~all, which marks other mail as suspicious but still delivers it, and ?all, which gives receivers no guidance at all. Start with ~all while testing, then switch to -all once your mail flows normally.

What is the 10 DNS lookup limit?

SPF allows at most 10 DNS lookups while checking a record. Each a, mx, and include mechanism costs one lookup, and includes can trigger more lookups inside the included record. If the count goes over 10, the receiver may stop checking and treat the result as an error, which can send good mail to spam. IP addresses cost no lookups, so use ip4 and ip6 when you know the exact sending addresses.

How do I add the SPF record to my domain?

Sign in to wherever your domain DNS is managed, usually your domain registrar or your hosting provider. Add a TXT record with the host set to your domain, paste the record from the builder above as the value, and save. Do not create a second SPF record if one already exists — edit the existing one and merge your senders into it.

How long does it take for an SPF record to work?

DNS changes usually take effect within a few hours, and can take up to 48 hours to reach every mail server. Test by sending mail to an address at another provider and checking whether it arrives in the inbox. If mail still fails after 48 hours, check that the record is on the right host and that there is only one SPF record for the domain.