You must follow the syntax outlined in the SPF specification for your SPF record to work properly. If you do not follow these syntax rules, your SPF record will fail the authentication check.
Common syntax errors
Here are some common SPF record syntax errors:
- Make sure there are no extra spaces before the start of the string (v=spf1).
- Make sure there are no extra spaces after the end of the string (~all).
- Check for misspellings in any of the mechanisms such as include, ip4, and more.
- Check for misspellings in any of the referenced domains.
- Remove the capitalization from the ip4 or ip6 mechanisms. (It is recommended to remove all upper case characters.)
- Remove any extra dashes prior to the hard fail mechanism. For example, change --all with –all.
- Make sure there are no commas and only one space in between each mechanism.
- Make sure your string starts with the type of TXT record it is. For example, make sure it starts with v=spf1 instead of beginning it with a different mechanisms such as ip4.
If none of these common errors are in your SPF record and you are still having issues, you should try copying and pasting the syntax into a non-formatting document tool such as Notepad. Sometimes unintended formatting issues occur when the syntax is copied and pasted from an email straight into DNS. This helps ensure there are no rare formatting mechanisms or unique characters that are unrecognizable by the mailbox provider’s server.
Examples of common SPF syntax errors:
- Missing authorization type (a.k.a. qualifier) with the all mechanism (~all, -all): “v=spf1 a mx ip4:192.168.0.1 all”
- Extra authorization type (a.k.a. qualifier) with the all mechanism (~all, -all): “v=spf1 a mx ip4:192.168.0.1 --all”
- Incorrect version (spf1): “v=spf a mx ip4:192.168.0.1 -all”
- Added space in the ip4 mechanism: “v=spf1 a mx ip 4:192.168.0.1 -all"
- Incomplete IP address: “v=spf1 a mx ip4:192.168.0. -all”
- Misspelled include mechanism: “v=spf1 a mx ip4:192.168.0.1 incude:example.com -all”
SPF record example
Here is an example of proper SPF syntax:
v=spf1 a mx ip4:192.168.0.1/16 include:example.com include:sendgrid.net ~all
Here’s a link to the SPF specification mentioned above: RFC7208.