What is an SPF record?

An SPF record is a DNS TXT record, beginning v=spf1, that lists the mail servers allowed to send email for your domain. Receiving servers compare the sending server with that list and treat unlisted senders as a pass, softfail or fail depending on how the record ends.

What SPF actually does

SPF stands for Sender Policy Framework. You publish it as a TXT record at your domain. When a receiving mail server accepts a message, it looks at the domain in the envelope sender (the Return-Path address used during the SMTP conversation), fetches that domain's SPF record and checks whether the connecting server's IP address is authorised.

Two details are often misunderstood. SPF checks the envelope sender, not the From address a person sees, so on its own it does not stop someone displaying your domain in the From line. And it checks the sending server, not the message content, so it says nothing about whether a message was altered in transit. DKIM and DMARC cover those gaps.

SPF record syntax

A record is a version tag followed by space-separated terms, read left to right. The first term that matches the sending IP decides the result. Each mechanism can have a qualifier in front: + pass (the default), - fail, ~ softfail and ? neutral.

  • ip4: and ip6: authorise an address or range directly and cost no DNS lookup
  • include: borrows another domain's SPF policy, such as your email provider's
  • a and mx authorise the addresses of your own A or MX hosts
  • all matches everything and so is placed last, with a qualifier that sets the default result
  • redirect= hands the whole decision to another domain's record
example.com.  IN  TXT  "v=spf1 include:_spf.google.com ip4:203.0.113.0/24 ~all"

How the record should end

The final all term sets what happens to everyone else. -all says unlisted servers are not authorised and mail from them should fail. ~all, a softfail, says they are probably not authorised and mail should be treated with suspicion but is usually accepted. ?all expresses no opinion. +all authorises every server on the internet and should never be used.

Many domains begin with ~all while they discover every service that sends for them, then move to -all. Either is valid. With DMARC in place the final choice matters less than getting the sender list complete and the record valid.

Mistakes that break SPF

Publishing two SPF records is the classic error: receivers return a permanent error and SPF fails, so merge senders into one record. Exceeding 10 DNS lookups has the same result, covered in our guide on the lookup limit. Other frequent faults are typos in include names, a missing space between terms, forgetting a service that sends mail for you, and using the deprecated ptr mechanism.

SPF also fails when mail is forwarded, because the forwarding server's address is not in your record. This is expected behaviour and is one reason DKIM is needed alongside it.

How DomainGuard helps

DomainGuard reads your SPF record with a live DNS query and reports on missing or duplicate records, malformed terms, the ending, the ptr mechanism and the number of lookup-causing terms in the record. On paid plans it re-checks on a schedule and alerts you when the record changes. It is read-only and does not edit your DNS or tell you which services you actually use.

Frequently asked questions

Where do I add an SPF record?

As a TXT record at the root of your domain in your DNS provider's control panel, with the name set to @ or the domain itself. Publish only one SPF record per domain.

Does SPF stop spoofing on its own?

No. SPF checks the envelope sender, not the visible From address, so it needs DKIM and DMARC alongside it to protect your domain name in the From line.

What is the difference between -all and ~all?

-all means unlisted servers should fail SPF. ~all means they are a softfail: suspicious but usually accepted. Both are valid; ~all is a common starting point.

Do I need SPF if I use Google Workspace or Microsoft 365?

Yes. Your provider gives you an include value to publish, and without the record receivers cannot verify the provider's servers are allowed to send as your domain.