sending emails prevent spam

A Comprehensive Guide to Preventing Email Spam: Demystifying SPF, DKIM, and DMARC

by Laurence Tuck

September 14, 2023

A Comprehensive Guide to Preventing Email Spam: Demystifying SPF, DKIM, and DMARC

by Laurence Tuck


Learn how to configure SPF, DKIM and DMARC DNS records, check authentication, troubleshoot email delivery and protect your business domain from spoofing.


SPF, DKIM and DMARC help protect your domain from impersonation and help receiving mail servers evaluate messages. They do not, on their own, guarantee that an email will reach the inbox or block all spam. This guide explains what they do, how to publish the DNS records and how to check that they work.

What are SPF, DKIM and DMARC?

SPF (Sender Policy Framework) identifies mail servers authorised to send using a domain in the message’s envelope sender address. DKIM (DomainKeys Identified Mail) uses a cryptographic signature to validate selected message headers and content. DMARC (Domain-based Message Authentication, Reporting and Conformance) checks whether an SPF or DKIM pass aligns with the domain people see in the From address, and lets the domain owner publish a policy and receive aggregate reports.

These technologies protect outgoing mail and make it harder for criminals to impersonate your domain. Receiving providers also combine authentication with reputation, content filtering and other signals when deciding whether to accept, reject or filter a message.

Before you add DNS records

  1. Identify your DNS host. Sign in where your domain’s authoritative nameservers are managed. This may be Cloudflare, your hosting company or your domain registrar. DNS changes made in an inactive zone will have no effect.
  2. List every service that sends email using your domain. Include Microsoft 365, Google Workspace, your website contact forms, WooCommerce order emails, newsletter software, CRMs and support systems.
  3. Inspect existing records. Update the current SPF record rather than adding a second one. Export or screenshot your DNS settings before making changes.
  4. Know what your provider requires. DKIM selectors and key values must come from the mail-sending service. Do not copy somebody else’s public key or make up an SPF include hostname.

How to add an SPF record

In your DNS dashboard, choose Add record > TXT (the exact wording varies by provider). For a domain that sends email exclusively through Google Workspace, the provider’s published SPF mechanism can be used as follows:

Field Example
Type TXT
Name / Host @ (or leave blank if your DNS provider uses the root domain)
Value v=spf1 include:_spf.google.com ~all
TTL Auto or the provider’s default

Use this Google example only if Google Workspace is your authorised sending service. Microsoft 365 and other services have different requirements. If several platforms send mail for your domain, their authorised sources must be combined into one SPF TXT record. SPF has a limit of 10 DNS-querying mechanisms/modifiers during evaluation; too many can cause a permanent error. The ~all ending indicates a soft fail for other senders, whereas -all is a hard fail. Choose an appropriate policy after verifying all legitimate senders.

How to add a DKIM record

  1. Sign in to the admin console of each mail-sending provider and enable or prepare DKIM signing for your domain.
  2. Generate the DKIM key or obtain the DNS records the service provides. For example, Google Workspace offers this under Apps > Google Workspace > Gmail > Authenticate email. Microsoft 365 typically supplies two DKIM CNAME records through its email authentication settings.
  3. In the authoritative DNS dashboard, add the provided TXT or CNAME record exactly as instructed. For TXT-based DKIM, the hostname often resembles selector1._domainkey and the value contains v=DKIM1; k=rsa; p=PUBLIC_KEY_FROM_PROVIDER. The selector and public key are specific to your service.
  4. Wait for DNS to resolve, then return to your mail provider to complete DKIM activation. Publishing the DNS key alone does not always enable message signing.

When several platforms send mail, each may use its own DKIM selector. Verify that at least one valid DKIM signature uses a domain aligned with the visible From address.

How to add a DMARC record

Once SPF and DKIM are configured, create a new TXT record at _dmarc under your domain. Begin with a monitoring policy while you validate every mail source:

Field Example
Type TXT
Name / Host _dmarc
Value v=DMARC1; p=none; rua=mailto:[email protected]
TTL Auto or provider default

Replace example.com with your own domain and use a real mailbox or DMARC reporting service that can receive and process aggregate reports. If you use an external reporting address, additional DNS authorisation may be required by the reporting destination. A record with p=none requests monitoring only. After confirming that legitimate senders pass DMARC, progressively move to p=quarantine and ultimately p=reject as appropriate. Enforcing a policy before checking all sending services can cause genuine messages to be filtered or rejected.

How to check that SPF, DKIM and DMARC work

  1. Check the DNS records. Use a DNS lookup tool to verify your domain has one valid SPF record, the correct DKIM record for each selector and a DMARC record at _dmarc.yourdomain.com.
  2. Send a real test email. Send from each service your business uses, including your website’s contact form and WooCommerce order notifications, to a mailbox you control.
  3. Inspect the message headers. Look for spf=pass, dkim=pass and dmarc=pass in the receiving system’s authentication results. DMARC needs at least one aligned SPF or DKIM pass, not necessarily both.
  4. Test deliverability separately. An inbox-placement test can help identify whether a sample message reaches inbox, promotions or junk folders. This is different from verifying your DNS records and is not a guarantee about future messages.
  5. Review DMARC reports. Look for unexpected senders or legitimate services failing authentication before strengthening your policy.

For independent verification, consult your provider’s authentication setup instructions and test using a mailbox you control. Third-party testing tools can be useful, but only send non-sensitive sample content because the testing service needs to receive the message. Email Spam Tester is one option for checking authentication results and testing sample-message placement. Its results are an additional diagnostic, not a guarantee of inbox delivery.

Common setup problems

  • Two SPF records: Combine the permitted senders into one SPF TXT record rather than publishing multiple v=spf1 records.
  • SPF passes, but DMARC fails: The envelope sender domain might not align with the visible From domain, and there may be no aligned DKIM signature.
  • DKIM fails: Verify the selector, key, CNAME target, provider activation and whether an intermediary modifies the signed message.
  • Forwarded emails fail SPF: Forwarding often changes the sending IP. A surviving aligned DKIM signature may still let DMARC pass.
  • DNS changes do not appear: Check which nameservers are authoritative and allow for the configured TTL and caching.

Frequently asked questions

Can I have more than one SPF record?

No. A domain must have only one SPF TXT record, although it can authorise multiple services within that record.

Do I need both SPF and DKIM for DMARC?

DMARC passes if SPF or DKIM passes with domain alignment. Configuring both improves resilience, especially when email is forwarded.

Will SPF, DKIM and DMARC stop my emails going to spam?

Not necessarily. Authentication helps, but reputation, recipient engagement, message content and other factors also affect inbox placement.

Should I set DMARC to reject immediately?

Only if you have verified all legitimate sending services. Most organisations should monitor first and then introduce enforcement carefully.

Do WordPress contact forms and WooCommerce emails need checking?

Yes. Website-generated messages may use a different sending server or return-path domain from your regular mailbox provider. Test real messages from the website, not just emails sent from Outlook or Gmail.

Need help configuring email authentication?

EditMe Websites can help audit your domain’s DNS, identify authorised sending services, configure SPF, DKIM and DMARC, and test WordPress and WooCommerce transactional email. Contact EditMe Websites if your messages are failing authentication or customers are not receiving order confirmations.

Useful references: Google Workspace SPF setup, Google Workspace DKIM setup, Google Workspace DMARC setup, and Microsoft’s authentication overview.


SHARE YOUR THOUGHTS