SPF is an email authentication protocol that specifies which mail servers are authorized to send email on behalf of your domain.
How SPF works:
- You publish an SPF record in your DNS as a TXT record:
v=spf1 include:_spf.example.com ~all - When a receiving server gets an email claiming to be from your domain, it checks the SPF record
- If the sending IP is listed as authorized, the email passes SPF
- If not authorized, it fails (with consequences depending on your DMARC policy)
SPF softfail vs. hardfail:
~all(softfail): Unauthorized sends are flagged but not rejected. Recommended during initial setup.-all(hardfail): Unauthorized sends are rejected. Use only when you're confident all legitimate senders are in your SPF record.
SPF 10-lookup limit: SPF allows a maximum of 10 DNS lookups (nested includes count). Exceeding this causes an SPF PermError, which counts as a failure. Use SPF flattening tools if you're approaching the limit.
SPF and forwarding: SPF breaks for forwarded email because the forwarding server's IP is not in your SPF record. This is why DKIM + DMARC are also required — DKIM survives forwarding.