SPF tells mail servers that your messages really come from you
SPF (Sender Policy Framework) is a record you add to your domain's DNS settings that tells other mail servers which computers are allowed to send email on your behalf. When someone receives a message from your domain, their mail server checks your SPF record to confirm the message actually came from a server you authorized. If the message came from a server not listed in your SPF record, the receiving server can reject it or mark it as suspicious.
Without SPF, anyone can send email claiming to be from your domain. A spammer could send a message that looks like it came from you@yourdomain.com, and the recipient's mail server has no way to verify whether that's true. SPF closes that gap by creating a public list of "these are the servers allowed to send mail from my domain."
SPF works alongside two other email authentication methods — DKIM (which cryptographically signs your messages) and DMARC (which tells servers what to do if authentication fails). Together, these three reduce the chance your legitimate mail gets blocked and make it harder for attackers to impersonate you.
Key Takeaways
- SPF is a DNS record that lists which mail servers can send email from your domain, and receiving servers check it to verify your messages are genuine.
- Your SPF record uses a straightforward text format and typically includes your mail provider's server addresses plus any third-party services that send mail on your behalf.
- Mail servers use SPF to decide whether to accept, reject, or flag incoming messages, so a missing or incorrect SPF record can cause your legitimate mail to be blocked.
- SPF alone does not may provide delivery — DKIM and DMARC provide additional verification — but it is the first step most mail systems check.
How SPF records work in practice
When you send an email from your domain, the receiving mail server performs a DNS lookup on your domain to find your SPF record. That record contains a list of authorized mail servers, written in a specific syntax. For example, a straightforward SPF record might look like this:
v=spf1 include:_spf.google.com ~all
This record says: "Version 1 of SPF, include the servers listed in Google's SPF record (because we use Gmail), and for any server not listed, treat it as a soft fail (~all means 'probably not authorized, but don't reject it outright')." The receiving server compares the IP address of the server that sent your message against this list. If it matches, the message passes SPF. If it does not match, the message fails.
The syntax can get more complex if you use multiple mail providers. For instance, if you send mail through both Gmail and Mailchimp, your SPF record needs to include both their server ranges. Each addition is another "include" statement or a direct IP address. The more services you add, the longer your record becomes, and there is a practical limit — SPF records cannot exceed 255 characters in a single DNS lookup, though you can work around this by chaining includes.
Where to add your SPF record
Your SPF record lives in your domain's DNS settings, usually managed through your domain registrar (GoDaddy, Namecheap, Google Domains) or your web hosting provider. You add it as a TXT record, not an A record or CNAME. The exact steps depend on your registrar, but the general process is: log in to your DNS management panel, create a new TXT record, paste your SPF record text, and save.
If you use a mail provider like Gmail, Microsoft 365, or Mailchimp, they usually provide the exact SPF record you should add. Check their documentation or support pages for the specific string. If you manage your own mail server, you will need to include your server's IP address or hostname in the record yourself.
After you add the record, it can take anywhere from a few minutes to 48 hours for DNS changes to propagate across the internet. During that time, some mail servers may see the old record and others the new one. Once propagation is complete, receiving servers will check your SPF record for every message sent from your domain.
Common SPF mistakes and how they affect delivery
The most common mistake is forgetting to add SPF entirely. Without a record, receiving servers have no way to verify your messages, so they may reject them or send them to spam. This is especially true for large providers like Gmail and Outlook, which rely heavily on SPF, DKIM, and DMARC to filter incoming mail.
Another frequent error is adding the wrong server addresses to your SPF record. If you use Mailchimp to send newsletters but your SPF record does not include Mailchimp's servers, messages from Mailchimp will fail SPF checks even though you authorized Mailchimp to send on your behalf. The receiving server sees a mismatch and treats the message as unauthorized.
A third mistake is using a hard fail (~all) when you should use a soft fail (~all). A hard fail (-all) tells receiving servers to reject the message outright if it comes from an unauthorized server. A soft fail (~all) tells them to accept it but mark it as suspicious. If you use a hard fail and accidentally add the wrong server to your record, your legitimate mail gets rejected. Soft fail is safer while you are testing.
SPF, DKIM, and DMARC work together
SPF alone is not enough to may provide your mail reaches the inbox. Large mail providers check multiple signals. DKIM adds a cryptographic signature to your messages so the receiving server can verify they have not been altered in transit. DMARC is a policy that tells receiving servers what to do if SPF or DKIM fails — accept it anyway, quarantine it, or reject it.
A complete email authentication setup includes all three. SPF verifies the sending server is authorized. DKIM verifies the message content has not been tampered with. DMARC enforces a policy based on the results of both checks. If you set up only SPF, your mail is more likely to reach the inbox than if you set up nothing, but you are missing two layers of protection.
Gmail, Outlook, and other major providers increasingly require all three for the best delivery rates. If you are sending bulk mail or transactional mail (password resets, order confirmations), setting up DKIM and DMARC alongside SPF is worth the effort.
Testing your SPF record
After you add your SPF record, you can check whether it is working using free online tools. Search for "SPF record checker" and enter your domain. The tool will perform a DNS lookup and show you the SPF record it found, along with whether it is valid syntax. This tells you whether your record was added correctly and is readable by mail servers.
A more thorough test is to send a test email from your domain to a mail provider's diagnostic service. Gmail, for example, offers a tool called the "Gmail Postmaster Tools" that shows you how your mail is being authenticated. You can see whether messages are passing SPF, DKIM, and DMARC checks, and whether they are landing in the inbox or spam folder.
If your SPF record is valid but mail is still being rejected, the problem may be elsewhere — your sending IP address might be on a spam blacklist, your mail server might be misconfigured, or the receiving server might have other filtering rules. SPF is one piece of the puzzle, not the whole solution.
When SPF is not enough
SPF checks the IP address of the server sending the mail, but it does not verify the message itself. A server listed in your SPF record could be compromised and used to send spam. DKIM solves this by signing the message with a private key only you control, so even if a server is compromised, an attacker cannot forge your signature.
SPF also does not protect against lookalike domains. If your domain is example.com, a spammer can register examp1e.com (with a 1 instead of an l) and set up their own SPF record. Recipients might not notice the difference, and the fake domain will pass SPF checks because the spammer controls it. DMARC can help by telling receiving servers to reject mail from domains that fail authentication, but it requires the receiving server to enforce the policy.
For these reasons, SPF is a necessary starting point but not a complete defense. If you are sending important mail — password resets, financial notifications, account changes — pair SPF with DKIM and DMARC for the strongest protection.
Frequently Asked Questions
Do I need SPF if I only send mail through Gmail or Outlook?
Yes. Even if you use Gmail or Outlook, you should add an SPF record to your domain so receiving servers can verify that mail claiming to come from your domain actually came from Gmail or Outlook's servers. Without SPF, your mail is more likely to be flagged as spam or rejected.
What does the ~all at the end of an SPF record mean?
The ~all is a soft fail, meaning "any server not listed in this record is probably not authorized, but accept the message anyway and let the receiving server decide what to do." A hard fail (-all) means "reject any message from an unlisted server." Use soft fail while testing, then switch to hard fail once you are confident your record is correct.
Can I have more than one SPF record for my domain?
No. DNS allows only one SPF record per domain. If you need to authorize multiple mail providers, add them all to a single SPF record using multiple include statements or IP addresses. If your record gets too long, you can chain includes to stay under the character limit.
How long does it take for an SPF record to start working?
DNS changes can take anywhere from a few minutes to 48 hours to propagate globally. Some mail servers will see your new record when ready, while others may still see the old one for up to two days. During this window, some of your mail may pass SPF checks and some may fail.
What happens if my SPF record has a syntax error?
Mail servers will either ignore the malformed record or reject it entirely. Either way, your SPF check will fail, and receiving servers will treat your mail as unverified. Use an SPF record checker tool to validate your syntax before adding it to DNS.