Skip to main content

Understanding SPF Records

An SPF record is a TXT record on your domain. It lists the servers that are allowed to send email for that domain.

When a mailbox provider receives your email, it checks the sending server against your SPF record. If the server is not listed, SPF fails.

A basic record​

v=spf1 include:example-provider.com ~all
  • v=spf1 says this is an SPF record.
  • include: pulls in the servers your provider uses.
  • ~all means "soft fail" everything else. Mail is marked but not always rejected.
  • -all means "hard fail" everything else. Use it only after you are sure every sender is listed.

Most providers tell you exactly which include value to use. Copy it from their DNS setup page.

Common provider examples​

These examples are common, but your provider's page is the source of truth.

ProviderInclude value
Amazon SESinclude:amazonses.com
SendGridinclude:sendgrid.net
Mailguninclude:mailgun.org
Mailjetinclude:spf.mailjet.com
Postmarkinclude:spf.mailpostmark.com
SparkPostinclude:spf.sparkpostmail.com
Mandrillinclude:spf.mandrillapp.com

If you send through more than one service, add each include to the same record. Do not create a second SPF record.

Only one SPF record per domain​

A domain can have many TXT records, but only one SPF record. If you publish two records that start with v=spf1, SPF breaks.

If you already have an SPF record from your host or another service, edit it. Add the new include inside the existing record.

Watch the lookup limit​

SPF allows a maximum of 10 DNS lookups. A lookup is one DNS question the receiving server must ask. Each include, a, mx, ptr, and exists can use one or more lookups.

A record with many includes can exceed the limit and fail even when it looks correct. If you run into this, remove services you no longer use or ask your provider for a solution.

Common mistakes​

MistakeResultFix
Two v=spf1 recordsSPF is invalidMerge them into one record
Missing provider includeSPF fails for that providerAdd the include from the provider
-all too earlyLegitimate mail is rejectedUse ~all until every sender is listed
Record on the wrong domainNo effectPut it on the domain used in the From address
Extra spaces or line breaksInvalid recordPublish it as one line

Check it​

dig TXT example.com

Look for one line that starts with v=spf1. If you see two, fix that first.

Next steps​