Email - Sender Policy Framework (SPF)

What is a a SPF record ?

SPF is a dns record that defines which server(s) may send an email. It describe the set of hosts which are designated outbound mailers for the domain.

SPF is part of the mail authentication scheme with DKCIM.

The SPF record value defines:

  • the mechanism of validation (where should a validator should get the IP of the server back)
  • and a qualifier attached (what actions to take if the validation fails)

If you are forwarding email (for instance with postfix virutal aliasing), the sender (ie gmail for instance) does not allow your server to send email on its behalf, you need to install what's called a Sender Rewriting Scheme (SRS) See Postfix - Sender Rewriting Scheme (SRS) installation


v=spf1 is a prefix that you will find in all record

  • -all: The domain sends no mail at all.
"v=spf1 -all"
  • Allow the host in the domain's MXes record to send mail for the domain, prohibit all others.
"v=spf1 mx -all"
  • +all Allow all host - The domain owner thinks that SPF is useless and/or doesn't care.
"v=spf1 +all"

Example of SPF dns record in the DNS zone provided by a domain registrar.


The optimal SPF record is composed of a:

v=spf1 [[qualifier]mechanism...] 

Validation Process

SPF looks up the DNS record for an e-mail's from address's host header.

Evaluation of an SPF record can return any of these results

Result Explanation Intended action
Pass The SPF record designates the host to be allowed to send accept
Fail The SPF record has designated the host as NOT being allowed to send reject
SoftFail The SPF record has designated the host as NOT being allowed to send but is in transition accept but mark
Neutral The SPF record specifies explicitly that nothing can be said about validity accept
None no SPF record at all or no value accept
PermError syntax or evaluation error (eg. badly formatted SPF record) unspecified
TempError dns processing error (dns server not reachable) accept or reject

Mechanism of validation

Mechanisms can be used to describe the set of hosts which are designated outbound mailers for the domain.


  • all represents all mechanisms (generally at the end of the SPF record)
# no mail is send by the domain
v=spf1 -all
# Only the mx mechanism
v=spf1 mx -all
# All mechanism are allowed (ie the admin don't care, generally not found)
v=spf1 +all


#Allow any IP address between and
# If no prefix-length is given, /32 is assumed 
# example
v=spf1 ip4: ~all
# any IPv6 address between 1080::8:800:0000:0000 and 1080::8:800:FFFF:FFFF.
# example
v=spf1 ip6:2001:4860:4000::/36 ~all


A: the whole domain

a: the A records for domain are tested (AAAA for ipv6). If the client IP is found among them, this mechanism matches

# the current dns domain is used (all servers defined in A records may send email)

A: List of mailers

# list all the outbound mailers in a special A record under

Create in the DNS zone multiple A record with the same name but differents IP IN A IN A IN A


# the mx record plus another emails server


  • include (from other domain ISP for instance)
# if has no SPF record, the result is PermError.


  • ovh hosting with the domain
  • mailchimp
  • and google
v=spf1 ~all


You have also:

  • ptr
  • exists

Mechanism Qualifier

Mechanisms can be prefixed with one of four qualifiers

  • + - Pass (default)
  • - - Fail
  • ~ - SoftFail
  • ? - Neutral


"v=spf1 -all"
"v=spf1 a -all"
"v=spf1 a mx -all"
"v=spf1 +a +mx -all"


Domains may also define modifiers. Each modifier can appear only once.

redirect | exp



with DNS - nslookup command line

nslookup -type=TXT
Server:  amplifi.lan

Non-authoritative answer:       text =

        "v=spf1 a -all"



Powered by ComboStrap