Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SPF Records: How to Add One & Authorize Your Domain Email

· 7 min read · Home Tech

In this article
  1. What Is an SPF Record and Why It Matters
  2. How SPF Works: The Check Process
  3. How to Add an SPF Record (Step-by-Step)
  4. Choosing the Right Mechanisms and Includes
  5. Common Problems and How to Avoid Them
  6. SPF vs. DKIM vs. DMARC
  7. Costs and Safety Considerations
  8. Frequently Asked Questions

To add an SPF record, you create a DNS TXT record at your domain host that lists the mail servers authorized to send email for your domain. This article explains how to build, publish, and test that record, plus common pitfalls and best practices.

What Is an SPF Record and Why It Matters

SPF (Sender Policy Framework) is an email authentication method that helps prevent spammers from sending email that appears to come from your domain. It works by publishing a list of IP addresses or hostnames that are allowed to send mail on your behalf. When a receiving server gets a message, it checks the SPF record of the claimed sender domain. If the sending server isn't on the list, the message may be marked as spam or rejected outright.

Without an SPF record, your domain is more vulnerable to spoofing, and legitimate email is more likely to land in junk folders. Most major email providers, including Gmail and Outlook, check SPF as part of their spam filtering. Adding SPF is one of the first steps in email authentication, alongside DKIM and DMARC.

How SPF Works: The Check Process

SPF relies on the domain in the envelope sender address (the MAIL FROM command), not the visible “From” header. Here's the simplified flow:

  1. A sender's mail server sends a message and identifies itself as mail.example.com.
  2. The receiving server looks up the TXT record for example.com.
  3. It reads the SPF record, which contains mechanisms like ip4:, include:, and a:.
  4. It checks the sending server's IP against those rules.
  5. It applies the qualifier (+ for pass, ~ for softfail, - for fail) and records the result.

For example, a record like v=spf1 ip4:192.0.2.10 include:_spf.google.com ~all tells receivers that only IP 192.0.2.10 and Google's listed servers may send mail; everyone else gets a softfail.

How to Add an SPF Record (Step-by-Step)

Adding an SPF record involves creating a DNS TXT entry at your domain registrar or DNS hosting provider. The exact steps vary by provider, but the general process is:

  1. Identify your sending sources. List all servers and services that send email for your domain: your own mail server IPs, third-party services like Google Workspace, Microsoft 365, SendGrid, or Mailchimp.
  2. Find the SPF record for each third-party service. Most providers publish a recommended include, such as include:_spf.google.com for Google Workspace or include:spf.protection.outlook.com for Microsoft 365.
  3. Build your record. Start with v=spf1, then add mechanisms for each source. Use ip4: for static IPs, include: for third-party services, and a or mx if your domain's A or MX records point to your mail server.
  4. End with a qualifier and all. Use ~all (softfail) for testing, then switch to -all (fail) once you're confident. Avoid +all which allows anyone to send.
  5. Publish the record. In your DNS provider's dashboard, create a new TXT record. The host/name is usually @ (your root domain) or left blank, and the value is your full SPF string.
  6. Test it. Use an online SPF lookup tool or send a test email and check the authentication headers.

Choosing the Right Mechanisms and Includes

The SPF record is composed of mechanisms that match against the sending IP. Here are the most common ones:

  • ip4: – matches a specific IPv4 address or CIDR range, e.g., ip4:192.0.2.10.
  • ip6: – same for IPv6 addresses.
  • a – matches the IP(s) in the domain's A record. You can specify a domain like a:mail.example.com.
  • mx – matches the IPs of the domain's MX servers.
  • include: – imports another domain's SPF record. This is how you authorize third-party services.
  • exists: – checks if a domain resolves; rarely used.
  • all – matches every IP. Always the last mechanism.

Each mechanism can have a qualifier: + (pass, default), - (fail), ~ (softfail), or ? (neutral). For example, -all means “reject all others,” while ~all means “mark as suspicious but accept.”

When you have multiple sending sources, you combine them in one record. Example for a domain using Google Workspace and a dedicated mail server at 192.0.2.10:

v=spf1 ip4:192.0.2.10 include:_spf.google.com ~all

You can have multiple include: statements, but be aware of the 10-DNS-lookup limit (explained below).

Common Problems and How to Avoid Them

Several mistakes can break SPF or cause legitimate mail to fail:

  • Multiple SPF records. You must have only one SPF TXT record for your domain. If you add a second, receivers may ignore both. Combine all mechanisms into a single record.
  • Missing all at the end. Without it, the record is incomplete and may be treated as neutral.
  • Exceeding the 10-DNS-lookup limit. Each include:, a, mx, and exists counts as a DNS lookup. If you exceed 10, SPF returns a permanent error. To reduce lookups, use ip4: for your own servers and avoid redundant includes.
  • Using +all. This tells receivers that anyone can send as your domain, defeating the purpose.
  • Forgetting to update the record when you change email providers. If you stop using a service, remove its include.

Another common issue is confusion between the envelope sender and the visible From address. SPF only checks the envelope domain. If you use a third-party service that sends with a different envelope domain, you may need to set up SPF for that domain, not yours.

SPF vs. DKIM vs. DMARC

SPF is one of three main email authentication standards. Understanding how they differ helps you build a complete defense:

  • SPF verifies the sending server's IP is authorized by the domain owner. It doesn't protect the visible From header.
  • DKIM (DomainKeys Identified Mail) uses a digital signature to verify the message wasn't altered in transit. It's tied to a domain in the DKIM-Signature header, which may differ from the From domain.
  • DMARC (Domain-based Message Authentication, Reporting, and Conformance) tells receivers what to do if SPF or DKIM fails, and it aligns the authenticated domain with the From domain. DMARC also provides reports so you can monitor spoofing attempts.

SPF alone is not enough for strong authentication, but it's a necessary first step. Many experts recommend implementing SPF, then DKIM, then DMARC.

Costs and Safety Considerations

Adding an SPF record is free—it's just a DNS entry. There are no licensing fees or per-record costs. The only “cost” is the time to configure it correctly and the risk of misconfiguration.

A misconfigured SPF record can cause legitimate email to be rejected, which can harm communication and business operations. To minimize risk:

  • Start with ~all (softfail) rather than -all to avoid hard failures while testing.
  • Monitor your email deliverability after publishing the record.
  • Use DMARC reports to see which sources are failing SPF and adjust.

Also note that SPF does not encrypt email or prevent phishing that uses your domain in the display name. It only authenticates the envelope sender. For full protection, combine SPF with DKIM and DMARC.

Frequently Asked Questions

Can I have more than one SPF record?

No. You should have exactly one SPF TXT record per domain. If you have multiple, receiving servers may merge them or ignore them, causing SPF to fail. Combine all mechanisms into a single record.

What does ~all vs -all mean?

~all is a softfail: the message is not authorized, but the receiver may still accept it (often marked as spam). -all is a hard fail: the receiver should reject the message. Use ~all during testing, then switch to -all once you're sure all legitimate sources are listed.

How do I find the SPF record for a third-party service?

Most providers document their SPF include in their help pages. For example, Google Workspace uses include:_spf.google.com, and Microsoft 365 uses include:spf.protection.outlook.com. You can also look up the provider's existing SPF record using an online tool or nslookup -type=TXT on their domain.

What is the 10-DNS-lookup limit?

SPF records can cause at most 10 DNS lookups when evaluated. Each include:, a, mx, and exists counts as one lookup. If you exceed 10, SPF returns a permanent error, and the message fails authentication. To avoid this, use ip4: for your own servers and combine includes where possible.

Do I need SPF if I only use a webmail service like Gmail?

Yes, if you send email from your own domain through a webmail service, you need an SPF record that includes that service. For example, if you use Google Workspace, you need include:_spf.google.com in your record. If you use a free Gmail account with your own domain, you still need to add the include.

How long does it take for an SPF record to work?

DNS changes propagate over time, usually from a few minutes to 48 hours. You can check propagation using online tools that query multiple DNS servers. Until the record is fully propagated, some receivers may not see it, so test after a day or two.