Wrinkles

Everyday skincare basics, explained plainly

SPF, DKIM, DMARC Setup Guide for Your Domain

· 5 min read · Ingredients Explained

Setting up SPF, DKIM, and DMARC for your domain is the most effective way to prevent email spoofing, reduce spam, and improve email deliverability. These three DNS records work together to verify that emails sent from your domain are legitimate and authorized by you. SPF (Sender Policy Framework) lists the servers allowed to send email for your domain; DKIM (DomainKeys Identified Mail) adds a digital signature to your emails; DMARC (Domain-based Message Authentication, Reporting, and Conformance) tells receiving servers what to do if an email fails SPF or DKIM checks. This guide walks you through creating and publishing each record, with practical steps and troubleshooting tips.

What You'll Need

  • Access to your domain's DNS settings (usually through your domain registrar or hosting provider's control panel).
  • Your email sending service's SPF and DKIM records (if you use a third-party email service like Google Workspace, Microsoft 365, or SendGrid, they provide these).
  • A text editor to copy and paste DNS values accurately.

Step-by-Step

  1. Identify your email sending sources. List all services that send email on behalf of your domain. This includes your email provider (e.g., Google Workspace, Outlook), marketing platforms, transactional email services, and any on-premises mail servers. You'll need to include each in your SPF record.
  2. Create your SPF record. An SPF record is a TXT record that starts with v=spf1. Add the IP addresses or domain names of your sending sources. For example, if you use Google Workspace and SendGrid, your SPF record might look like: v=spf1 include:_spf.google.com include:sendgrid.net ~all. The ~all at the end is a soft fail (recommended for most), while -all is a hard fail. Start with ~all to avoid blocking legitimate email during setup.
  3. Publish the SPF record. In your DNS provider's control panel, create a new TXT record. Set the host/name to @ (your root domain) and the value to your SPF record. Save it. Note that DNS changes can take up to 48 hours to propagate, but usually within a few hours.
  4. Generate your DKIM key. Most email providers generate a DKIM key pair for you. For example, in Google Workspace, go to Apps > Google Workspace > Gmail > Authenticate email, and generate a new key. You'll get a DNS TXT record with a host name (like google._domainkey) and a value (like v=DKIM1; k=rsa; p=MIGfMA0...).
  5. Publish the DKIM record. In your DNS control panel, create a new TXT record. Use the host name provided by your email provider (e.g., google._domainkey) and paste the entire value. Save it.
  6. Enable DKIM signing. After the DNS record propagates, go back to your email provider and click "Start authentication" (or similar). This tells your provider to sign outgoing emails with the DKIM key.
  7. Create your DMARC policy. A DMARC record is a TXT record at _dmarc.yourdomain.com. The value starts with v=DMARC1. A basic policy looks like: v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com. The p=none means no action is taken on failing emails, but you receive reports. rua is the email address to receive aggregate reports.
  8. Publish the DMARC record. Create a new TXT record with host _dmarc and value as above. Save it.
  9. Monitor and adjust. After a few days, review the DMARC reports you receive. If you see legitimate emails failing, check your SPF and DKIM alignment. Once you're confident, change p=none to p=quarantine (send to spam) or p=reject (block) to enforce your policy.

Common Mistakes

  • Multiple SPF records: You can only have one SPF record for your domain. If you add a second, both are ignored and SPF fails. Combine all includes into a single record.
  • SPF record too long: SPF records have a 255-character limit for the entire string. If you exceed it, the record is invalid. Use include: mechanisms instead of listing many IPs.
  • Using -all too early: If you use a hard fail before all legitimate senders are included, you may block your own email. Start with ~all.
  • DKIM key length: Some providers require a 2048-bit key, but older systems may only support 1024-bit. Check your provider's documentation.
  • Forgetting DMARC alignment: DMARC requires alignment of the domain in the From header with the domain in SPF or DKIM. If you send from a subdomain or a different domain, it may fail. Use the same domain for all.

Tips

  • Use a DMARC record with rua to receive XML reports. Tools like Postmark's DMARC inspector or dmarcian can parse them for you.
  • Keep a record of all your sending sources in a spreadsheet so you can update SPF as you add new services.
  • Test your DNS records with online tools like MXToolbox or Google Admin Toolbox. They check for syntax errors and propagation.
  • If you use a subdomain for sending (e.g., mail.yourdomain.com), you can set up a separate SPF and DKIM for that subdomain to keep your root domain's record simpler.

Troubleshooting

  • Emails going to spam: Check if your SPF and DKIM pass by sending a test email to a tool like Gmail's Message Header Analyzer. Look for spf=pass and dkim=pass. If they fail, verify the DNS records are correct and propagated.
  • DMARC reports not showing up: Ensure the rua email address is correct and that you've set up the _dmarc TXT record exactly. Some providers require a separate mailbox for DMARC reports; check that it exists.
  • SPF permerror: This means your SPF record has a syntax error or exceeds the 10-lookup limit. Use include: wisely and consider using a subdomain to reduce lookups.
  • DKIM signature missing: If your email provider isn't signing, ensure you've enabled DKIM in their settings after publishing the DNS record. Also, check the selector name (e.g., google) matches the host.

Frequently Asked Questions

How long does it take for DNS records to propagate?

Usually within a few hours, but it can take up to 48 hours. Use online DNS checkers to see when your records are live globally.

Can I have multiple DKIM records?

Yes, you can have multiple DKIM records with different selectors (e.g., one for Google, one for SendGrid). They are distinguished by the host name. You can also have multiple SPF records? No, only one SPF record per domain.

What is DMARC alignment?

DMARC alignment checks that the domain in the From header matches the domain used in SPF or DKIM. Strict alignment requires an exact match; relaxed alignment allows subdomains.

What does p=none mean?

It means DMARC is in monitoring mode. No action is taken on emails that fail authentication, but you receive reports. It's recommended for initial setup.

Do I need all three records?

Yes, for full protection. SPF and DKIM alone can be bypassed; DMARC ties them together and tells receivers what to do with unauthenticated mail.

What if I use a third-party email service?

Most email services provide their own SPF and DKIM records. You just add them to your DNS. They also often have specific DMARC guidance. Follow their documentation.

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