SPF

SPF (Sender Policy Framework) is an email authentication method that helps prevent email spoofing by specifying which mail servers are allowed to send email on behalf of a domain.

Purpose

SPF answers one simple question:

Is this server allowed to send email for this domain?

If the answer is no, the email can be marked as spam or rejected.

How SPF Works

  1. Domain owner publishes an SPF record in DNS.
  2. The SPF record lists authorized mail servers (IP addresses or services).
  3. When an email is received:
    • The receiving server checks the sending server’s IP.
    • It compares that IP against the domain’s SPF record.
  4. The result is pass, fail, softfail, neutral, etc.

Example SPF Record

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

This means:

  • ip4:192.0.2.10 → Allowed IP
  • include:_spf.google.com → Allow Gmail servers
  • -all → Reject mail from any other server

SPF Results

  • Pass → Authorized sender
  • Fail (-all) → Unauthorized sender (often rejected)
  • SoftFail (~all) → Suspicious but accepted
  • Neutral (?all) → No clear policy

Limitations

  • SPF only checks the sending IP, not the message content.
  • It breaks with email forwarding, unless combined with DKIM.
  • SPF alone doesn’t enforce policy—that’s where DMARC comes in.

SPF vs DKIM (Quick Comparison)

FeatureSPFDKIM
ChecksSending IPMessage signature
Uses DNSYesYes
Survives forwarding❌ No✅ Yes
Prevents spoofing✅ Yes✅ Yes

In short: SPF helps email servers verify that a message came from an authorized mail server for a domain.