Guides SPF
What is SPF?
SPF states which servers may send for your domain. Check your provider’s settings and test that your own mail passes.
Your mail provider sends email for example.com. You publish a list of servers allowed to send for that domain. SPF checks the sending server against that list.
One message from example.com
Your mail provider delivers a message to the receiving mail server, using example.com as the sender domain.
The receiver looks up the list of permitted servers for example.com in the domain settings, known as DNS. It then compares the IP address of the server offering the message with that list. If the server is permitted, the check passes. That result is called pass.
If the server is not on the list, the result follows the rules you published for that case. The receiver considers that result alongside its own filters and policy. The SPF result does not automatically lead to rejection.
Which sender address is checked?
An email has the sender address you see in your mail app. Mail servers also pass a return address between them for delivery-failure notices. SPF uses the domain of that technical return address.
For example, you see info@example.com and the return address is bounce@example.com. Both use example.com here. The SPF setting for example.com therefore applies to the delivery.
In technical data, the visible sender field is called From. The return address passed between servers is called MAIL FROM, also known as the envelope address. You will see these names in provider settings and test messages. Ask the sending service which return-path domain it uses, since this can differ from the visible sender domain.
What does an SPF record look like?
The permitted servers and the rules for other servers are published together in one DNS text record: the SPF record. It starts with v=spf1. The receiver evaluates its rules from left to right for the sending server's IP address. The first matching rule determines the result.
A typical record: v=spf1 include:_spf.google.com ~all. Piece by piece:
v=spf1: identifies an SPF record (required at the start)include:_spf.google.com: matches when the SPF evaluation at that target returnspass~all: addresses not matched earlier getsoftfail
The building blocks you can use:
aandmx: addresses of the named host or mail serversip4:andip6:: individual addresses or ranges, such asip4:192.0.2.0/24include:: references another SPF policy- the sign before
allsets the result for addresses that reach it:-all(fail),~all(softfail),?all(neutral) or+all(pass). An unintended+allcan therefore authorize everyone
Setting it up step by step
Start with your sending services: mail provider, newsletter tool, CRM, web shop and invoicing system. Ask each which MAIL FROM domain it uses, also called the envelope or return-path domain. This determines which SPF record the receiver queries.
For example, a message shows From: info@example.com but uses MAIL FROM: bounce@bounces.example.com. SPF queries the TXT record at bounces.example.com. The SPF record at example.com does not automatically apply there. If the service uses its own return-path domain, it manages that SPF policy. An include at your visible sender domain does not change that check.
- Ask each provider for its current settings for the chosen return-path domain. Do not copy includes for services you do not use
- Edit the existing SPF record at that name and combine only the required
include:,ip4:orip6:terms. Keep other TXT records - Use
~allwhile your sender inventory remains uncertain. Consider-allonly after checking legitimate senders and forwarding paths - Check the full DNS name and value after publishing, then test real mail from every service
The example v=spf1 include:_spf.google.com ~all is suitable only if Google Workspace is the sole sender for that domain. Always follow the provider's current instructions. In a DNS panel, choose TXT. For example.com, Name/Host is often @ or blank. For bounces.example.com, it is often bounces. Some panels append the domain automatically. Check that you have not created bounces.example.com.example.com. Old answers can remain cached until their previous TTL expires.
Checking real mail
Scan the name where you published SPF. This checks DNS and the evaluation paths examined, not whether a real message passes SPF. Send a test message from each sending service to a mailbox you control. View the original headers there and the result added by your receiving mail server.
For example: spf=pass smtp.mailfrom=bounces.example.com. This shows which domain the receiver checked. It does not yet confirm the visible sender address. DNS Radar's Mailheaders tool can make these reported results easier to read. It does not run the SPF check again or prove who wrote pasted headers.
If one service fails, first check its actual return-path domain, the provider's required settings and the sending IP reported by the receiver. Fix the record at the right name and test again. A DNS error or timeout does not prove the record is absent. A passing test at this receiver does not tell you how other receivers or later messages will behave.
What SPF does not say about the visible sender
The technical return-path domain can differ from the sender domain you see. A passing SPF check for that return-path domain therefore does not automatically confirm the visible sender address. A separate check provides that link: DMARC. It asks whether a passing server check or a passing signature check belongs to the visible sender domain. The signature check is called DKIM. See the DMARC and DKIM guides for more detail.
Forwarding can cause SPF to fail: a different server offers the mail and may not be on the original sender's list. A failed check therefore does not prove abuse. Mail with a pass can still contain harmful content or be blocked by the receiver. Without SPF, this published server permission is absent, but other checks and spam filters can still work.
Mail servers can also check the name with which the sending server introduces itself. This is the HELO identity. DMARC uses the MAIL FROM identity. For an empty return path, SPF derives that identity from HELO.
The 10-lookup limit
The limit counts DNS-triggering terms, not every individual DNS query. One evaluation may process at most 10 reached include, a, mx, ptr, exists and redirect terms. Nested includes and redirects share that budget. ip4, ip6 and all do not use it. Additional limits apply to operations such as MX address queries.
Take v=spf1 include:_spf.a.example include:_spf.b.example -all. The first include costs one term. If it contains an a mechanism that is reached, that costs another term. If that include returns pass for the sender, evaluation stops: the second include is never reached. If the first include does not match, the second can count too. Counting only the visible includes therefore misses part of the path.
Exceeding the term limit produces permerror: the SPF rules could not be evaluated correctly. This differs from none (no SPF information). The receiver decides handling through its local policy. The specification also recommends a limit of two DNS lookups where the name or requested record is absent (void lookups). Receivers that apply this limit can stop with permerror as well.
Without a concrete sending IP, DNS Radar examines proven and possible paths. A possible upper bound above ten is not a confirmed failure for every sender. Remove unused references first. Flattening replaces includes with IP ranges, but is appropriate only if someone keeps up with provider changes.
Common mistakes
- Publishing more than one selected SPF record: this produces
permerror - Exceeding 10 DNS-triggering terms on an evaluation path
- An unintended
+all: every address that reaches it getspass - Forgetting a real sending service, so legitimate mail can fail SPF
- Using
ptr: the SPF specification advises against publishing it
Primary sources
Frequently asked questions
What's the difference between ~all and -all?
-all returns fail for addresses not matched earlier: not authorized. ~all gives the weaker softfail result. The receiver decides handling. Neither guarantees delivery. Map all senders and forwarding paths before tightening the policy.
Is SPF enough to stop spoofing?
No. SPF checks the server for the technical return-path domain, not automatically the sender address you see. DMARC adds the check of that visible domain, using a passing server or signature check as evidence. Even this does not prevent every form of phishing or sender abuse.
Can I have multiple SPF records?
Not at the same name. If you publish SPF, use one SPF record there. Multiple selected SPF records make the rules unusable. That error is called permerror. Combine senders using the same return-path domain in that record. Other TXT records, such as verification codes, can sit alongside it.
Do I need SPF if my domain sends no mail?
For a domain that sends no mail, you can publish v=spf1 -all. This declares that no server may use it as the technical sender domain. It does not independently block abuse of the visible sender address. DMARC is the additional check for that visible domain.
My SPF has too many lookups. What now?
First remove includes you no longer use. Sending streams with their own return-path domain can have a separate SPF record. Flattening is another option, but requires ongoing maintenance of the provider's IP ranges. A list copied once can become outdated.