What is SPF?

SPF is a DNS record that lists the servers allowed to send email for your domain. Inboxes check it on every message, and mail from anywhere else can be sent to spam or rejected.

Updated · 7 min read

TXTacme.com
Verified

v=spf1 include:_spf.google.com include:spf.useplunk.com ~all

Your receipt from Acme

From billing@acme.com

Sent by
spf.useplunk.com
SPF
Pass

How SPF works

Anyone can put your domain in the From line of an email. SPF is how a receiving server tells real mail from forged mail: it compares the server that delivered the message with the list you published.

  1. You publish a record

    A TXT record on your domain lists every service and IP address allowed to send for it.
  2. A message arrives

    The receiving server notes the IP address of the server that delivered it.
  3. It looks up your record

    It fetches the SPF record for the domain in the message’s return path.
  4. Pass or fail

    If the IP is on the list, SPF passes. If not, it fails, and the message may be filtered or rejected.

Your receipt from Acme

From billing@acme.com

Sent by
Plunk
SPF
Pass

Urgent: verify your account

From billing@acme.com

Sent by
Unknown server
SPF
Fail
Same From address, two servers. Only the listed one passes.

Reading an SPF record

An SPF record is one line of text. It starts with the version, lists the allowed senders, and ends with what to do about everyone else.

TXT record on acme.com
v=spf1 include:_spf.google.com include:sendgrid.net ip4:192.0.2.1 ~all
PartWhat it means
v=spf1The SPF version. Every record starts with this.
include:sendgrid.netAllow every server listed in another domain’s SPF record. This is how you add a provider.
ip4:192.0.2.1Allow one IPv4 address, or a range such as 192.0.2.0/24.
ip6:2001:db8::1Allow one IPv6 address or range.
aAllow the IP addresses in the domain’s A record.
mxAllow the servers in the domain’s MX records.
~allSoft fail: accept mail from anyone else, but mark it as suspicious.
-allHard fail: reject mail from anyone else.

Why SPF matters

  • Stops spoofing

    Forged mail from servers you did not list fails the check.
  • Helps you reach the inbox

    Gmail, Yahoo and Outlook expect bulk senders to pass SPF.
  • Protects your domain

    Phishing that uses your name is easier for inboxes to catch.
  • Needed for DMARC

    DMARC builds on SPF and DKIM results.

How to set up SPF

  1. List everything that sends as you

    Your mailbox provider, your product’s email service, your help desk, your newsletter tool.
  2. Collect each service’s include

    Every provider documents the value to add.
    ValueService
    include:_spf.google.comGoogle Workspace
    include:spf.protection.outlook.comMicrosoft 365
    include:spf.useplunk.comPlunk
  3. Combine them into one record

    v=spf1 include:_spf.google.com include:spf.useplunk.com ~all
  4. Add it to your DNS

    Create a TXT record at the root of your domain, usually written as @. Replace any SPF record that is already there rather than adding a second one.
  5. Check it

    Run your domain through the SPF checker to confirm the record is valid and under the lookup limit.

Common mistakes

  • Two SPF records

    A domain can only have one. With two, both are ignored and SPF fails. Merge them.
  • Too many lookups

    Each include adds at least one lookup. Past 10, every message fails.
  • Forgetting a new tool

    When you start sending from a new service, add it to the record the same day.
  • Ending with +all

    +all lets any server in the world pass. Use ~all or -all.

Keep reading

Frequently asked questions

Get SPF right the first time.

Start on the free plan with 1,000 emails a month, no credit card needed. When you need more, every email is $0.001, with unlimited contacts and every feature included.