Domains

How to Set Up SPF, DKIM and DMARC on Your Domain

Set up SPF, DKIM, and DMARC on your domain to protect your email from spoofing and prevent your messages from landing in spam.

Abstract image of ethereal fiber optic strands cascading with glowing blue lights.

To prevent your emails from landing in spam — or someone impersonating your domain — you need to configure three DNS authentication records: SPF, DKIM, and DMARC. Together, they prove to receiving servers that your emails are legitimate.

What Are SPF, DKIM, and DMARC and Why Do They Matter?

These three protocols form the authentication layer of email. Without them, anyone can send an email "from" your domain, and spam filters may reject even your legitimate messages.

  • SPF (Sender Policy Framework): declares which servers are authorized to send email on behalf of your domain. Stored as a TXT record.
  • DKIM (DomainKeys Identified Mail): adds a cryptographic signature to every email that receiving servers verify using a public key in your DNS. Stored as a TXT record under a special subdomain.
  • DMARC (Domain-based Message Authentication, Reporting and Conformance): defines what receiving servers should do when an email fails SPF or DKIM, and where to send you reports. Stored as a TXT record at _dmarc.yourdomain.com.

Since 2024, Google and Yahoo require SPF + DKIM + DMARC for senders who send more than 5,000 messages per day. For all domains, having all three active significantly improves deliverability.

How to Configure the SPF Record

SPF is a TXT record in your DNS zone. Its basic format is:

v=spf1 include:_spf.google.com ~all

Each part has a meaning:

  • v=spf1: protocol version (always this value).
  • include:_spf.google.com: authorizes Google Workspace servers. Replace this with your email provider's include: (e.g. include:spf.protection.outlook.com for Microsoft 365).
  • ~all: "softfail" policy — emails from unauthorized servers are flagged but not rejected. Use -all (hardfail) once you're confident the SPF is correct.

Steps to Add the SPF Record in cPanel

  1. Go to cPanel → Zone Editor → Manage.
  2. Click Add Record.
  3. Name: @ (or leave blank for the root domain).
  4. Type: TXT.
  5. Value: paste your SPF string (e.g. v=spf1 include:_spf.google.com ~all).
  6. Save.

Important: you should only have one SPF record per domain. If one already exists, edit it rather than adding another, or SPF will fail.

How to Configure DKIM

DKIM uses a key pair (public/private). Your email provider holds the private key and signs each outgoing message. You publish the public key in DNS so any server can verify the signature.

Getting Your DKIM Key from Your Provider

  • Google Workspace: Admin Console → Apps → Google Workspace → Gmail → Authenticate email → Generate new record. Copy the TXT record it generates.
  • Microsoft 365: Security Admin Center → Email & collaboration → DKIM → select domain → Enable. Microsoft gives you CNAME records to publish (instead of a TXT).
  • cPanel / Shared Hosting: go to cPanel → Email Authentication → enable DKIM. cPanel generates and publishes the record automatically.

DKIM Record Format

The record name is typically selector._domainkey.yourdomain.com, where selector is an identifier defined by your provider (e.g. google, s1, mail). The value is a long TXT string like:

v=DKIM1; k=rsa; p=MIIBIjANBgkq...

Copy the value exactly as your provider gives it to you. Don't modify it — a single incorrect character invalidates the signature.

How to Configure DMARC

Once SPF and DKIM are working, add the DMARC record. Always start in monitor mode (policy none) to receive reports without affecting delivery:

v=DMARC1; p=none; rua=mailto:[email protected]
Parameter Meaning Possible values
p Policy for failing emails none (monitor), quarantine (spam), reject (block)
rua Aggregate report address A mailto: on your domain
pct Percentage of messages to apply policy to 0–100 (default 100)
adkim DKIM alignment r (relaxed, default), s (strict)

Steps to Add DMARC in cPanel

  1. Zone Editor → Add Record.
  2. Name: _dmarc.
  3. Type: TXT.
  4. Value: v=DMARC1; p=none; rua=mailto:[email protected].
  5. Save and wait for reports (usually arrive within 24–48 hours).

After analyzing reports for 2–4 weeks without issues, raise the policy to quarantine and then to reject for maximum protection.

If you need help setting up professional email for your business from scratch, the specialists at elenlace.com can manage the entire process for you.

For more guides on DNS configuration and domains, visit our domains blog.

Verifying That SPF, DKIM, and DMARC Are Working

Once the records are published (wait at least 30 minutes), verify everything is correct:

  • MXToolbox (mxtoolbox.com/SuperTool.aspx): analyzes SPF, DKIM, and DMARC by simply entering your domain.
  • Mail-tester.com: send a test email and receive a score from 1 to 10 with details on each protocol.
  • Google Admin Toolbox (toolbox.googleapps.com): Google's official tool for diagnosing deliverability issues.

A score of 10/10 on mail-tester.com with all three protocols active indicates optimal configuration.

Key Takeaways

  • SPF declares which servers can send mail on your behalf — a single TXT record at the root domain.
  • DKIM cryptographically signs each email — get the public key from your provider and publish it as a TXT record under selector._domainkey.
  • DMARC defines what to do when SPF or DKIM fail — start with p=none, analyze reports, then escalate to reject.
  • There can only be one SPF record per domain; edit the existing one rather than adding a new one.
  • Since 2024, Google and Yahoo require all three protocols for bulk senders.
  • Use MXToolbox or mail-tester.com to verify everything is working correctly.

Want your emails to reach the inbox instead of spam? Contact the team at elenlace.com and we'll configure SPF, DKIM, and DMARC on your domain today.

FAQ

Do I need to configure all three protocols (SPF, DKIM, and DMARC)?

For complete protection, yes. SPF and DKIM are complementary: SPF verifies the sending server; DKIM verifies the content wasn't altered. DMARC ties them together and adds a response policy. Without DMARC, even with SPF and DKIM active, an attacker can still spoof your domain in certain scenarios.

Can I have multiple SPF records on the same domain?

No. The RFC specifies that only one SPF record (a TXT starting with v=spf1) can exist per domain. If you need to authorize multiple providers, combine them in a single record using multiple include: directives. Example: v=spf1 include:_spf.google.com include:spf.sendgrid.net ~all.

How long does it take for DMARC to work after publishing it?

The DMARC record appears in DNS within minutes (depending on TTL), but the first aggregate reports arrive 24–48 hours later. Major providers like Gmail and Outlook typically send the previous day's report in the early morning hours.

What happens if I enable DMARC with reject policy too soon?

You could block legitimate email if there are still sending sources not covered by your SPF record or that don't have DKIM properly configured. That's why starting at p=none is recommended — review reports for several weeks and raise the policy gradually: none → quarantine → reject.

Compare providers

Other providers and guides worth comparing:

← All