Wrinkles

Everyday skincare basics, explained plainly

How to Add SPF Records: A Step-by-Step Guide

· 5 min read · Ingredients Explained

Adding an SPF (Sender Policy Framework) record tells receiving mail servers which IP addresses or hostnames are allowed to send email on behalf of your domain. This helps prevent spammers from forging your domain in the "From" field, which improves email deliverability and reduces the chance your legitimate emails land in spam. You'll need access to your domain's DNS settings, typically through your domain registrar or hosting provider's control panel.

What You'll Need

  • Access to your domain's DNS management interface (e.g., cPanel, Cloudflare, GoDaddy, Namecheap, or your hosting provider).
  • The list of IP addresses or hostnames that currently send email for your domain (e.g., your web server's IP, your email service provider's sending servers, or third-party services like SendGrid or Mailchimp).
  • A basic understanding of DNS record types (TXT records, in particular).

Step-by-Step

  1. Identify all email senders for your domain. List every service that sends email using your domain: your own mail server, your website's contact form, transactional email providers, marketing tools, etc. You'll need their IP addresses or hostnames. If you're unsure, check your email sending service's documentation or support page.
  2. Construct your SPF record. The basic format is: v=spf1 [mechanisms] -all. Start with v=spf1. Then add mechanisms for each sender. For example:
    • ip4:192.0.2.1 – allows a specific IPv4 address.
    • ip6:2001:db8::1 – allows a specific IPv6 address.
    • include:spf.example.com – includes the SPF record of another domain (commonly used by email services).
    • a – allows the domain's A record IP.
    • mx – allows the domain's MX record hosts.
    End with -all to hard-fail all other senders (recommended for most domains) or ~all for a soft fail (if you're still testing). Example: v=spf1 ip4:192.0.2.1 include:spf.sendgrid.net -all.
  3. Log in to your DNS management panel. Go to the domain's DNS settings or zone editor. This is usually found under "DNS Management", "DNS Records", or "Advanced Settings".
  4. Add a new TXT record. Look for an option to add a new record, then select "TXT" as the record type.
  5. Enter the record details. In the "Name" or "Host" field, enter @ (or leave it blank if your provider uses that convention) to apply to the root domain. In the "Value" or "Content" field, paste your SPF record exactly as you wrote it, enclosed in double quotes if your provider requires it (most do not).
  6. Save the record. Click "Save" or "Add Record". Your SPF record is now live, but DNS propagation may take up to 48 hours.
  7. Verify your SPF record. After a few hours (or up to 48 hours), use an online SPF lookup tool or a command like nslookup -type=TXT yourdomain.com to confirm the record is present and correctly formatted.

Common Mistakes

  • Having more than one SPF record. This causes SPF to fail entirely. You must have exactly one SPF TXT record for your domain.
  • Using +all or no ending mechanism. This essentially allows any server to send mail as your domain, defeating the purpose.
  • Exceeding the 10-lookup limit. SPF records can include multiple include: statements, but each one counts toward a maximum of 10 DNS lookups. Too many will cause permanent errors.
  • Forgetting to include all legitimate senders. If you miss an IP, emails from that server will fail SPF and may be rejected.
  • Using the wrong syntax. A missing space or a typo can invalidate the record. Always double-check the exact format.

Tips

  • Start with ~all (soft fail) while testing, then switch to -all once you're confident all legitimate senders are included.
  • Use an SPF record generator tool from a reputable source to avoid syntax errors.
  • Keep a copy of your SPF record in a secure place for reference.
  • If you use multiple email services, use include: statements for each service's domain rather than listing IPs manually when possible.
  • Monitor your email deliverability after making changes; if you see legitimate emails bouncing, check your SPF record for missing senders.

Troubleshooting

If your SPF record isn't working as expected:

  • Check for multiple SPF records. Use a DNS lookup tool to see all TXT records for your domain. If there's more than one starting with v=spf1, remove the duplicates, keeping only the one that includes all senders.
  • Look for syntax errors. Many online tools will validate your SPF record and point out errors. Common issues include missing spaces, incorrect IP format, or using include: with a domain that has no SPF record.
  • Wait for DNS propagation. Changes can take up to 48 hours to spread globally. Test again after that period.
  • Check if your email provider requires additional records. Some services (like Google Workspace) may require you to add a specific SPF value provided by them. Follow their instructions.
  • If emails are still failing, test with a tool like SPF Checker. It will simulate an email from your domain and show you the SPF result (pass, fail, softfail). Use that to identify which sender is not allowed.

Frequently Asked Questions

What does an SPF record look like?

A typical SPF record is a TXT record with a value like: v=spf1 ip4:192.0.2.1 include:_spf.google.com -all. It starts with v=spf1, lists allowed senders, and ends with an all-encompassing rule.

Can I have multiple SPF records?

No. You should have exactly one SPF record for your domain. If you have multiple, receiving servers may reject all of them, causing SPF to fail.

How long does SPF take to work?

DNS changes typically propagate within a few hours, but can take up to 48 hours. You can check after a few hours, but allow a full two days for complete propagation.

What is the difference between -all and ~all?

-all tells receiving servers to reject any email that doesn't match the SPF record (hard fail). ~all tells them to accept it but mark it as suspicious (soft fail). Use ~all during testing, then switch to -all for better security.

Do I need an SPF record if I use a third-party email service like Gmail or Outlook?

Yes, if you send email from your own domain through those services, you need an SPF record that includes their sending servers. Most providers document the exact SPF value to use.

What should I do if my SPF record is too long?

If you're hitting the 10-lookup limit, try consolidating include: statements or using a subdomain for some services (e.g., mail.example.com) and set up a separate SPF record for that subdomain. Alternatively, consider using a dedicated email service that provides a single include.

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions