SPF Implementation Guide
Secure your email with Sender Policy Framework
Learn how to implement and manage SPF (Sender Policy Framework) records to prevent email spoofing and improve deliverability.
What is SPF?
SPF (Sender Policy Framework) is an email authentication method that allows domain owners to specify which mail servers are authorized to send email on their behalf. It helps prevent email spoofing and is a key component of DMARC authentication.
Implementation Steps
1. Identify Email Sources
Document all sources that send email on behalf of your domain:
- Your mail servers (MX records)
- Third-party email services (e.g., SendGrid, Mailchimp, Google Workspace)
- Marketing platforms
- Cloud services (e.g., AWS SES, Azure)
- Any other authorized senders
This inventory is crucial for creating a complete SPF record.
2. Create SPF Record
Create your SPF record with all authorized senders:
v=spf1 include:_spf.google.com include:sendgrid.net ip4:192.0.2.0/24 ~all
Common mechanisms:
include:domain.com- Include another domain's SPF recordip4:192.0.2.0/24- Authorize IP addresses (IPv4)ip6:2001:db8::/32- Authorize IP addresses (IPv6)a- Authorize A recordsmx- Authorize MX records~all- Soft fail for all other sources-all- Hard fail for all other sources
3. Test Your SPF Record
Use our SPF validation tool to test your configuration:
Test your SPF record to ensure it's valid and stays within the 10-lookup limit:
Test Your SPF Record4. Optimize Lookup Count
Ensure your SPF record stays within the 10-lookup limit:
- Replace
include:mechanisms with directip4:orip6:where possible - Remove unnecessary include statements
- Use SPF flattening services if needed
- Consolidate multiple includes from the same provider
Each include, a, mx, and exists mechanism consumes DNS lookups. IP-based mechanisms (ip4, ip6) do not.
Best Practices
RFC 7208 limits SPF records to 10 DNS lookups. Exceeding this limit causes permerror.
Only one SPF record is allowed per domain. Multiple records will cause SPF to fail.
Use ip4/ip6 mechanisms instead of include when possible to reduce lookup count.
Use ~all initially to monitor impact before switching to -all (hard fail).
Always test your SPF record with validation tools before making DNS changes.
While not strictly required, keeping records under 512 characters is recommended for compatibility.
Common Issues and Solutions
Lookup Limit Exceeded
If your SPF record requires more than 10 DNS lookups, receiving servers will return a permerror. Replace include mechanisms with direct IP addresses where possible, or use SPF flattening services.
Multiple SPF Records
Only one SPF record is allowed per domain. If you have multiple TXT records starting with "v=spf1", combine them into a single record.
Syntax Errors
Common syntax errors include invalid mechanism names, missing colons in include statements, and invalid IP address formats. Use validation tools to identify and fix these issues.
Test Your Implementation
Use our SPF testing tool to verify your configuration and lookup consumption:
Test Your SPF Configuration