SPF record syntax

An SPF record is a single DNS TXT record that starts with v=spf1 and lists the mechanisms describing who may send mail for your domain. Here is the full syntax.

Anatomy of a record

v=spf1 include:spf.protection.outlook.com ip4:198.51.100.0/24 a mx -all

Mechanisms

MechanismAuthorizesCounts as lookup?
ip4: / ip6:a specific IP or CIDR rangeNo
athe domain’s A/AAAA record IPsYes
mxthe domain’s MX host IPsYes
include:another domain’s SPF recordYes (recursively)
exists:a dynamic macro checkYes (one)
redirect=replaces the record with another’sYes
ptrreverse-DNS (deprecated — don’t use)Yes

Qualifiers

Each mechanism can carry a qualifier that sets the result when it matches:

Size and count limits

Common syntax mistakes

Frequently asked questions

What is the correct SPF record format?
A single TXT record beginning with v=spf1, followed by mechanisms (include, ip4, a, mx, etc.) and ending with an all qualifier such as ~all or -all.
What is the 255-character limit in SPF?
A single DNS TXT string can be at most 255 characters. Longer SPF records are published as multiple quoted strings that DNS concatenates — still a single valid record.
What does ~all vs -all mean?
~all is softfail (mark suspicious), -all is hardfail (reject). The all mechanism sets the result for senders not otherwise matched.

Test your SPF record now

Validate your record’s syntax and lookup count in one check.

Test My SPF Records →

Free check · no signup required to see your lookup count.