All guides
Term

SPF

An email authentication method that specifies the mail servers authorized to send email on behalf of a domain via a DNS record.

SPF (Sender Policy Framework) is an email authentication method that specifies which mail servers are authorized to send email on behalf of a domain via a DNS record. By publishing a list of approved sending IP addresses and third-party services, domain owners help receiving mail servers detect and block sender address forgery, commonly known as spoofing. Alongside DKIM and DMARC, SPF serves as a foundational layer for email deliverability and domain reputation.

How it works

To implement SPF, a domain administrator publishes a specially formatted TXT record in the domain's DNS zone. When an incoming message arrives, the receiving mail server inspects the domain in the SMTP MAIL FROM (Return-Path) address and queries DNS for its SPF policy. The server then compares the connecting client's IP address against the authorized sources listed in the record.

An SPF record consists of a version prefix followed by mechanisms and qualifiers:

  • v=spf1: Identifies the TXT record as an SPF policy.
  • ip4 and ip6: Explicitly authorize specific IPv4 or IPv6 addresses and CIDR ranges.
  • include: Authorizes another domain's SPF policy, commonly used for cloud email providers or marketing platforms.
  • -all (HardFail) or ~all (SoftFail): Qualifiers placed at the end of the record to instruct receivers on how to treat unmatched IPs, signaling either outright rejection or suspicious marking.

Example

A domain using Microsoft 365 for corporate email and a dedicated application server with a static IPv4 address would publish a single DNS TXT record at the root domain (@):

v=spf1 ip4:203.0.113.25 include:spf.protection.outlook.com -all

You can verify that the record is live and properly propagated using the dig command in a terminal:

dig +short TXT example.com

What matters when choosing a server or hosting

When selecting a VPS, dedicated server, or managed hosting provider for workloads that send transactional email, network and DNS stability are critical. Your host should provide static, dedicated IPv4 and IPv6 addresses so your ip4 and ip6 mechanisms remain valid without frequent DNS edits. Clean IP reputation also matters: shared hosting environments often place multiple tenants on the same outbound mail IP, meaning another user's spam activity can hurt your deliverability even with a valid SPF record.

Additionally, look for hosting platforms or DNS providers that offer fast propagation, API-driven DNS management, and support for outbound SMTP relay services if your host blocks standard mail ports by default.

Common mistakes

  • Publishing multiple SPF records: A domain must have only one v=spf1 TXT record. Having two or more causes receiving servers to return a PermError, invalidating SPF completely.
  • Exceeding the 10-DNS-lookup limit: Mechanisms such as include, a, mx, and redirect trigger DNS queries. If resolving a record requires more than 10 lookups, authentication fails with a PermError.
  • Using +all: The +all qualifier authorizes every server on the internet to send email as your domain, defeating the purpose of SPF.
  • Forgetting third-party senders: Failing to add include statements for CRM tools, ticketing systems, or web forms causes legitimate automated emails to land in spam.

FAQ

Does SPF protect the "From" address visible to users?

Not directly. SPF validates the technical Return-Path address used during SMTP transport rather than the header From address displayed in email clients. To align and protect the visible sender address, you must pair SPF with DMARC.

What is the difference between -all and ~all?

The -all (HardFail) qualifier tells receiving servers that unauthorized senders should be rejected, while ~all (SoftFail) indicates that unauthorized mail should be accepted but flagged as suspicious. Most administrators use ~all during initial testing and switch to -all once all legitimate mail sources are verified.

How can I fix an SPF record that exceeds 10 DNS lookups?

You can reduce lookups by removing unused include entries, replacing hostname-based mechanisms with direct ip4 or ip6 ranges where possible, or delegating transactional and marketing emails to dedicated subdomains with their own separate SPF records.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.