Email - Sender Policy Framework (SPF)

1 - 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

3 - Example

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.

4 - Syntax

The optimal SPF record is composed of a:

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

5 - 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

6 - Mechanism of validation

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

6.1 - All

  • 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

6.2 - IP

#Allow any IP address between and
# If no prefix-length is given, /32 is assumed 

# any IPv6 address between 1080::8:800:0000:0000 and 1080::8:800:FFFF:FFFF.

6.3 - A

6.3.1 - 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)

6.3.2 - 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

6.4 - Mx

# the mx record plus another emails server

6.5 - Include

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

Example ovh hosting with the domain

v=spf1 ~all

6.6 - Other

You have also:

  • ptr
  • exists

7 - 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"

8 - Modifiers

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

redirect | exp

9 - Test

10 - Query

with DNS - nslookup command line

nslookup -type=TXT

Server:  amplifi.lan

Non-authoritative answer:       text =

        "v=spf1 a -all"

11 - Reference

12 - Documentation

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap