SPF Best Practices
Optimize your SPF records for maximum security and deliverability. Expert strategies for qualifiers, lookup management, and long-term maintenance.
1. Use the Right "all" Qualifier
The all qualifier determines what happens to emails that don't match your SPF record. Choosing the right one is critical for security and deliverability.
-all (Fail)
v=spf1 include:_spf.google.com -allRecommended for production. Rejects unauthorized emails outright.
~all (SoftFail)
v=spf1 include:_spf.google.com ~allRecommended for testing. Marks unauthorized emails as suspicious but delivers them.
?all (Neutral)
v=spf1 include:_spf.google.com ?allNot recommended. Provides no guidance to receiving servers.
+all (Pass)
v=spf1 include:_spf.google.com +allNEVER use. Allows anyone to send email from your domain.
Start with ~all for 2-4 weeks to test, then move to -all for production security.
2. Stay Under 10 DNS Lookups
The 10 lookup limit is strictly enforced. Exceeding it causes PermError and email delivery failures.
Quick Checklist:
3. Use Subdomains Strategically
Separate different email types across subdomains to isolate lookup counts and improve organization.
Recommended Subdomain Strategy:
example.comPrimary domainCorporate email (Google Workspace, Microsoft 365)
v=spf1 include:_spf.google.com -all3 lookups
marketing.example.comMarketing subdomainMarketing emails (SendGrid, Mailchimp)
v=spf1 include:sendgrid.net include:servers.mcsv.net -all2 lookups (isolated)
app.example.comApp subdomainTransactional emails (Postmark, AWS SES)
v=spf1 include:spf.mtasv.net include:amazonses.com -all2 lookups (isolated)
Benefit: Each subdomain has its own 10 lookup limit. Total capacity: 30+ lookups across all domains.
4. Keep SPF Records Simple and Readable
Good Example
v=spf1 include:_spf.google.com include:sendgrid.net -all- ✓Clear and concise
- ✓Only necessary mechanisms
- ✓Easy to audit
Bad Example
v=spf1 mx a include:_spf.google.com include:old-esp.com include:unused.net ip4:192.0.2.1 ip4:192.0.2.2 ~all- ✗Cluttered and long
- ✗Unused mechanisms (mx, a, old ESPs)
- ✗Hard to maintain
5. Document Your SPF Configuration
Maintain documentation of your SPF setup for easier troubleshooting and team handoffs.
What to Document:
v=spf1 include:_spf.google.com include:sendgrid.net -allLast updated: 2025-01-15 | DNS Lookups: 4/10
- • Google Workspace - include:_spf.google.com (3 lookups)
- • SendGrid - include:sendgrid.net (1 lookup)
- • 2025-01-15: Removed Mailchimp (no longer used)
- • 2024-12-01: Added SendGrid for marketing
- • 2024-10-10: Moved to -all from ~all (production ready)
6. Monitor SPF Performance Regularly
Common SPF Mistakes to Avoid
Multiple SPF Records
Only one SPF record allowed per domain. Multiple records cause PermError.
Using mx or a Without Need
Most organizations don't send email from web/mail servers. Remove these to save lookups.
Forgetting Subdomains
Subdomains need their own SPF records or inherit parent domain policy.
Not Testing Before Production
Always start with ~all for 2-4 weeks to catch issues before enforcing -all.
Exceeding 255 Characters
SPF records have a 255-character limit per string. Use subdomains if you hit this limit.