SPF: tell the world who can send your email
SPF (Sender Policy Framework) is a list, published in DNS, of the servers allowed to send email that claims to be from your domain. A receiving server checks the list. If the sender is not on it, the message looks suspicious.
What a record looks like
It is a TXT record on the root of your domain.
example.ca. 3600 IN TXT "v=spf1 +a +mx ip4:203.0.113.25 include:spf.protection.outlook.com ~all"
Read it left to right.
| Part | Meaning |
|---|---|
v=spf1 |
Required. Says this is an SPF record, version 1. |
+a |
The IP in the domain's A record may send. + means allow and is the default. |
+mx |
The servers in the MX records may send. |
ip4:203.0.113.25 |
This IPv4 address may send. |
ip6:2001:db8::25 |
An IPv6 address, if you use one. |
include:spf.protection.outlook.com |
Also allow whatever that domain's SPF allows. Used for services like Microsoft 365 and Google Workspace. |
~all |
Everything else: softfail. Accept but mark as suspicious. |
The final word
| Ending | Name | What it tells receivers |
|---|---|---|
-all |
Hardfail | Reject anything not listed |
~all |
Softfail | Accept, but treat as suspicious. Best while you test. |
?all |
Neutral | No opinion |
+all |
Pass all | Never use. Allows anyone. |
Begin with ~all. Move to -all when you are sure every sender is listed. DMARC does most of the enforcing, so ~all with a DMARC policy is common. See DMARC.
Examples
Barbrick only.
example.ca. 3600 IN TXT "v=spf1 +a +mx ip4:203.0.113.25 ~all"
Note: Your real record also includes our outgoing mail relay, so it is longer than these examples. Copy it from Account → Hosting → your site → Email → Deliverability rather than typing it, then add other services to that copy.
Barbrick mailboxes plus Microsoft 365.
example.ca. 3600 IN TXT "v=spf1 +a +mx ip4:203.0.113.25 include:spf.protection.outlook.com ~all"
Google Workspace only.
example.ca. 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
Barbrick plus a newsletter service.
example.ca. 3600 IN TXT "v=spf1 +a +mx ip4:203.0.113.25 include:_spf.newsletter.example ~all"
The include value for each service comes from the service's setup guide.
Rules
- One SPF record per name. Two records cause a permanent error. Merge them.
- 10 DNS lookups at most.
include,a,mx,ptr, andexistseach cost a lookup, and nested includes count. Over 10 gives apermerror, and SPF fails.ip4andip6cost nothing. - Under 255 characters per string. Long records are split into quoted chunks.
- Only the domain in the envelope sender is checked (the Return-Path), not the visible From address. That is why DKIM and DMARC matter too.
- Forwarding breaks SPF. When a server forwards a message, it sends from a new IP. See Forward email.
Check yours
dig +short TXT example.ca
"v=spf1 +a +mx ip4:203.0.113.25 ~all"
In Account → Hosting → your site → Email → Deliverability, check the SPF row shows Valid. See Deliverability.
Edit it in your Barbrick account
- Go to Account → Hosting → your site → DNS.
- Find the TXT record starting with
v=spf1and select Edit record. - Make changes, then select Save record.
See Add, edit, and delete DNS records.
If something goes wrong
spf=permerror. Two SPF records, or too many lookups.spf=softfailfor your own mail. The sending server is missing. Add itsincludeor IP.- Website forms fail. Add the site's sending server. See Website contact forms not sending email.
Still stuck? Ask us and we'll walk you through it.