Wrinkles

Everyday skincare basics, explained plainly

SPF Record: What It Is & How DNS Email Auth Works

· 6 min read · Ingredients Explained

An SPF record is a type of DNS (Domain Name System) record that lists which mail servers are allowed to send email on behalf of your domain. SPF stands for Sender Policy Framework. Its purpose is to help prevent email spoofing, where attackers forge the “From” address to make phishing or spam emails look like they come from your domain. When you publish an SPF record, receiving mail servers can check it to verify that an incoming message claiming to be from your domain actually came from an authorized server.

How SPF Records Work

SPF works by publishing a specially formatted TXT record in your domain’s DNS settings. This record contains a list of IP addresses or hostnames that are permitted to send email for your domain. When an email is sent, the receiving mail server looks up the SPF record for the domain in the “From” address (the envelope sender, technically). It then compares the IP address of the server that delivered the message against the list in the record. If the IP matches, the email passes the SPF check. If not, it fails or returns a “softfail,” depending on the policy you set.

Here is a simple example of an SPF record:

v=spf1 ip4:192.0.2.1 include:_spf.example.com -all

This record says: “The domain’s version is SPF1, the IP 192.0.2.1 is allowed to send, also include the SPF record of _spf.example.com, and reject all other senders (-all).”

SPF Record Syntax and Tags

An SPF record is a single string of text starting with v=spf1. After that, you add mechanisms and qualifiers. The most common mechanisms are:

  • ip4: – allows a specific IPv4 address or range (e.g., ip4:203.0.113.5).
  • ip6: – allows a specific IPv6 address or range.
  • include: – pulls in the SPF record of another domain (e.g., include:spf.example.net). This is often used by email service providers.
  • a – allows the domain’s A record IP address.
  • mx – allows the domain’s MX (mail exchange) servers.
  • exists: – performs a DNS lookup to check if a given domain exists.
  • all – matches every IP not already matched; always placed at the end.

Qualifiers define what to do if a mechanism matches. They are placed before the mechanism, though a missing qualifier defaults to + (pass). The qualifiers are:

  • + – pass (allow)
  • - – fail (reject)
  • ~ – softfail (accept but mark)
  • ? – neutral (no opinion)

For example, -all at the end means “reject anything not listed above.” ~all means “accept but flag it as suspicious.”

Why SPF Alone Is Not Enough

SPF has a critical limitation: it only checks the envelope sender (the return-path), not the visible “From” address that users see. An attacker can set the envelope sender to a domain they control (which passes SPF) while displaying your domain in the “From” header. This means SPF alone cannot fully prevent spoofing. That is why SPF is almost always used together with DKIM (DomainKeys Identified Mail) and DMARC (Domain-based Message Authentication, Reporting, and Conformance). DMARC tells receiving servers what to do if both SPF and DKIM fail, and it also requires that the domain in the “From” address aligns with the domain used in SPF or DKIM.

How to Create and Publish an SPF Record

Creating an SPF record involves a few steps:

  1. Identify all legitimate email senders for your domain. This includes your own mail server, any third-party email service (like Google Workspace or Microsoft 365), and any marketing or transactional email platforms.
  2. Write the SPF record. Start with v=spf1, then add each sender using the appropriate mechanism. End with -all if you want strict rejection, or ~all for a softer policy.
  3. Publish the record as a TXT record in your DNS settings. The host/name is usually @ (your domain) or empty, depending on your DNS provider.
  4. Test the record using an SPF lookup tool or by sending a test email.

Important: SPF records have a limit of 10 DNS lookups. Each include, a, mx, or exists counts as a lookup. If you exceed 10, the record is considered invalid and will fail. Keep your record concise and avoid unnecessary includes.

Common SPF Problems and Misconfigurations

Several issues frequently arise with SPF records:

  • Too many DNS lookups – exceeding 10 causes the record to be invalid.
  • Missing -all or ~all – without a final “all” mechanism, the record is permissive, meaning any server can send as your domain.
  • Using multiple SPF records – only one TXT record with v=spf1 is allowed. If you have more than one, they will conflict and may cause failures.
  • Incorrect syntax – a typo like ip4 instead of ip4: can break the whole record.
  • Not including all legitimate senders – if you forget to include a service you use, emails from that service will fail SPF.

If you see SPF failures in your email logs, check the record for these issues. Many email providers offer diagnostic tools.

SPF vs. DKIM vs. DMARC

SPF, DKIM, and DMARC work together but serve different purposes:

  • SPF – verifies the sending server’s IP address against a list of authorized IPs.
  • DKIM – uses a digital signature to verify that the email content wasn’t tampered with and that it comes from a domain that authorized the signing.
  • DMARC – tells receiving servers what to do if both SPF and DKIM fail, and provides reporting on authentication results.

Think of SPF as a bouncer checking ID at the door, DKIM as a tamper-evident seal on the package, and DMARC as the manager who decides what to do if the seal is broken or the ID is fake. All three are needed for robust email authentication.

Frequently Asked Questions

What is an SPF record used for?

An SPF record is used to prevent email spoofing by listing which IP addresses or servers are allowed to send email for your domain. Receiving mail servers check this record to verify that incoming email claiming to be from your domain actually originated from an authorized server.

How do I check my SPF record?

You can check your SPF record using online tools like MXToolbox or by running a command like nslookup -type=TXT yourdomain.com on your computer. The tool will show you the TXT records, and you can look for one starting with v=spf1.

What does “include” mean in an SPF record?

The include mechanism lets you import the SPF record of another domain. For example, if you use Google Workspace, you include _spf.google.com, which contains Google’s list of sending IPs. This saves you from having to list every IP yourself.

Can I have more than one SPF record?

No, you should only have one SPF record with v=spf1. If you have multiple, receiving servers may reject or ignore them, causing authentication failures. If you need to add more senders, edit the existing record.

What is the difference between -all and ~all?

-all means “fail” – any email not matching the record is rejected. ~all means “softfail” – the email is accepted but marked as suspicious. Softfail is often used during testing to avoid blocking legitimate email.

Does SPF stop all email spoofing?

No. SPF only checks the envelope sender, not the visible “From” address, so attackers can still spoof your domain by using a different envelope sender. That is why you need DKIM and DMARC to fully protect your domain.

In this article
  1. How SPF Records Work
  2. SPF Record Syntax and Tags
  3. Why SPF Alone Is Not Enough
  4. How to Create and Publish an SPF Record
  5. Common SPF Problems and Misconfigurations
  6. SPF vs. DKIM vs. DMARC
  7. Frequently Asked Questions