Email Authentication Best Practices: A Comprehensive Guide

Detailed best practices for implementing and maintaining email authentication protocols including SPF, DKIM, and DMARC. [Request ID: 67ee6c34a75b21743678516]

Email authentication is a critical aspect of modern email communication, designed to combat spam, phishing, and spoofing attempts. This comprehensive guide dives deep into the best practices for implementing and maintaining robust email authentication protocols, including Sender Policy Framework (SPF), DomainKeys Identified Mail (DKIM), and Domain-based Message Authentication, Reporting, and Conformance (DMARC). By following these guidelines, organizations can enhance their email security, improve deliverability, and protect their reputation.

Understanding Email Authentication Protocols

Before delving into the best practices, it's essential to understand the three primary email authentication protocols: SPF, DKIM, and DMARC. Each protocol serves a specific purpose in validating the authenticity of an email message.

Sender Policy Framework (SPF)

SPF is an email validation system that allows domain owners to specify which mail servers are authorized to send emails on behalf of their domain. SPF works by publishing a DNS record that lists the IP addresses or hostnames of the legitimate mail servers. When an email is received, the receiving server checks the SPF record of the envelope sender (MAIL FROM or Return-Path) domain to verify that the sending server is authorized. SPF does not look at the From address your recipients see.

SPF, DKIM and DMARC side by side. SPF lists the servers allowed to send for a domain. DKIM signs each message so receivers can confirm it is unchanged. DMARC requires SPF or DKIM to pass and match the From domain, sets a policy and sends reports.
What SPF, DKIM and DMARC each check
  1. Sender's mail server sends an email to the recipient's mail server.
  2. Recipient's mail server takes the domain from the envelope sender (the MAIL FROM address, which later appears as the Return-Path), or from the HELO name if the envelope sender is empty.
  3. Recipient's mail server queries the sender's domain's DNS for the SPF record.
  4. DNS server returns the SPF record, which contains a list of authorized IP addresses or hostnames.
  5. Recipient's mail server compares the sending server's IP address with the authorized list in the SPF record.
  6. If the IP address matches, the email passes SPF authentication; otherwise, it fails.

Implementing SPF

To implement SPF, follow these steps:

  1. Identify all mail servers and third-party services that send email on behalf of your domain.
  2. Create an SPF record for your domain, listing the IP addresses or hostnames of the authorized mail servers.
  3. Publish the SPF record in your domain's DNS.
  4. Test your SPF record using online tools to ensure proper configuration.

Keep the record within the limit of 10 DNS lookups. Each include, a, mx and redirect counts, and a record that needs more than 10 fails SPF.

Example SPF record:
v=spf1 ip4:192.0.2.0/24 ip6:2001:db8::/32 include:thirdparty.com -all

DomainKeys Identified Mail (DKIM)

DKIM is an email authentication method that uses cryptographic signatures to verify the authenticity of an email message. The sending mail server digitally signs selected email headers and the body using a private key, and the receiving server verifies the signature using the corresponding public key published in the sender's DNS.

  1. Sender's mail server generates a DKIM signature from selected headers and a hash of the body, using the private key.
  2. The signature is added to the email headers, and the email is sent to the recipient's mail server.
  3. Recipient's mail server extracts the DKIM signature and the sender's domain from the email headers.
  4. Recipient's mail server queries the sender's domain's DNS for the DKIM public key.
  5. DNS server returns the DKIM public key.
  6. Recipient's mail server verifies the DKIM signature using the public key. If the signature is valid, the email passes DKIM authentication; otherwise, it fails.

Implementing DKIM

To set up DKIM for your domain, follow these steps:

  1. Generate a public-private key pair for your domain.
  2. Configure your mail server to sign outgoing emails using the private key.
  3. Publish the public key in your domain's DNS as a DKIM record.
  4. Test your DKIM setup using online tools to ensure proper signing and verification.
Example DKIM record:
default._domainkey.example.com IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQPOLGDsX+GcYcGE0e84Cj7pPB2jSBub7Jm0ZyO2sRXEBWoQo/tndn34ZfSXzmbHHpYSWwqTN/0wgqF6ot1HvOGcg2TGrv0fUbGp9J5SqnUOP9NzMhbFoaKPXdkBvxDfpAh3KPwhKCMFb32zPKDiMILNXU62SBXSx8uNHd/0XJRQIDAQAB"

Domain-based Message Authentication, Reporting, and Conformance (DMARC)

DMARC is an email authentication protocol that builds upon SPF and DKIM. It allows domain owners to specify how receiving mail servers should handle messages that fail DMARC. A message passes DMARC if SPF or DKIM passes and the passing domain aligns with the domain in the From header; one aligned pass is enough. DMARC also provides a feedback mechanism for receiving servers to report back to the sender's domain about the authentication results.

  1. Sender's mail server sends an email to the recipient's mail server.
  2. Recipient's mail server performs SPF and DKIM authentication checks.
  3. Recipient's mail server extracts the sender's domain from the email's "From" header and checks for a DMARC record in the DNS.
  4. DNS server returns the DMARC record, which contains the domain owner's policy for handling failed authentication and reporting instructions.
  5. Recipient's mail server checks whether SPF or DKIM passed with a domain that aligns with the From domain. If neither did, it applies the DMARC policy.
  6. Receivers that support reporting send aggregate reports (usually daily) to the address in the rua tag, summarizing the authentication results for your domain.

Implementing DMARC

To set up DMARC for your domain, follow these steps:

  1. Ensure that SPF and DKIM are properly configured for your domain.
  2. Create a DMARC record for your domain, specifying the policy for handling failed authentication and the reporting email address.
  3. Publish the DMARC record in your domain's DNS.
  4. Monitor DMARC reports and adjust your SPF and DKIM configurations as needed.
Example DMARC record:
_dmarc.example.com IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc-reports@example.com; ruf=mailto:dmarc-forensics@example.com; rf=afrf; adkim=r; aspf=r"

Email Authentication Best Practices

Now that we've covered the basics of SPF, DKIM, and DMARC, let's explore the best practices for implementing and maintaining these email authentication protocols.

1. Implement All Three Protocols

To achieve the highest level of email security and deliverability, it's crucial to implement all three authentication protocols: SPF, DKIM, and DMARC. Each protocol serves a unique purpose and complements the others. Since 2024, Gmail and Yahoo require SPF, DKIM and DMARC from bulk senders.

Benefits of Implementing All Three Protocols
  • SPF verifies that the sending IP is allowed to send for the envelope sender domain.
  • DKIM ensures the integrity of the email content and headers.
  • DMARC provides a policy framework for handling failed authentication and reporting.

2. Keep Records Up to Date

As your email infrastructure evolves, it's essential to keep your SPF, DKIM, and DMARC records up to date. Regularly review and update your records to ensure they accurately reflect your current mail servers, third-party services, and policies.

Common Pitfalls:
  • Forgetting to update SPF records when adding new mail servers or services.
  • Not rotating DKIM keys periodically.
  • Failing to adjust DMARC policies based on authentication results and feedback.

3. Choose the Right Alignment Mode

DMARC supports two alignment modes. Relaxed alignment (the default) passes when the authenticated domain shares the same organisational domain as the From header, so mail.example.com aligns with example.com. Strict alignment requires an exact match. Relaxed alignment suits most senders, because email service providers often sign or send from a subdomain. Use strict alignment only when you know every legitimate source authenticates with the exact From domain.

Example DMARC record with strict alignment:
_dmarc.example.com IN TXT "v=DMARC1; p=reject; adkim=s; aspf=s; rua=mailto:dmarc-reports@example.com"

4. Implement a Gradual DMARC Rollout

When first implementing DMARC, it's best to start with a "none" policy (p=none) and gradually progress to stricter policies, such as "quarantine" (p=quarantine) and "reject" (p=reject). This allows you to monitor the authentication results and identify any misconfigurations before enforcing strict policies that may impact email deliverability.

The following diagram illustrates a recommended DMARC rollout plan:
DMARC rollout in four stages: publish p=none and collect reports, fix any legitimate senders that fail, move to p=quarantine, then move to p=reject once reports are clean.
A safe path from monitoring to full DMARC enforcement
  1. Start with a "none" policy (p=none) to gather feedback and monitor authentication results.
  2. Analyze DMARC reports and identify any issues with SPF and DKIM authentication.
  3. Correct any misconfigurations in SPF and DKIM.
  4. Progress to a "quarantine" policy (p=quarantine) to start enforcing authentication.
  5. Monitor the impact of the "quarantine" policy and make necessary adjustments.
  6. Finally, implement a "reject" policy (p=reject) to enforce strict authentication and protect against spoofing.

5. Monitor and Analyze DMARC Reports

DMARC reports provide valuable insights into the authentication results of emails sent from your domain. Regularly monitor and analyze these reports to identify potential issues, such as misconfigurations, unauthorized senders, or spoofing attempts.

Key Metrics to Monitor in DMARC Reports
  • SPF and DKIM pass/fail rates
  • Alignment rates for SPF and DKIM
  • Sources of failed authentication attempts
  • Volume of emails sent from your domain

6. Use DKIM Key Rotation

To maintain the security of your DKIM signatures, it's crucial to rotate your DKIM keys periodically. Key rotation helps protect against potential key compromises and ensures that your DKIM signatures remain secure over time.

  • Generate new key pairs periodically (e.g., every 6 months).
  • Publish the new public key in your DNS before transitioning to the new key pair.
  • Allow for an overlap period where both old and new keys are valid.
  • Gradually phase out the old key pair and remove it from your DNS once the transition is complete.

7. Educate Your Organization

Implementing email authentication protocols is not just a technical task; it also requires cooperation and understanding from various stakeholders within your organization. Educate your team members, especially those involved in email marketing, customer support, and IT, about the importance of email authentication and the best practices they should follow.

Education Topics:
  • The benefits of email authentication for deliverability and security
  • The role of each protocol (SPF, DKIM, and DMARC)
  • Best practices for creating and sending authenticated emails
  • The importance of monitoring and reporting

Conclusion and Next Steps

Email authentication is a critical component of a robust email security strategy. By implementing SPF, DKIM, and DMARC and following the best practices outlined in this guide, organizations can protect their domains from spoofing, improve email deliverability, and maintain a trusted reputation.

  1. Implement SPF, DKIM, and DMARC for every service that sends email as your domain.
  2. Start DMARC at p=none, read the aggregate reports and fix any legitimate sources that fail.
  3. Move to p=quarantine and then p=reject once your reports are clean.
  4. Review your records whenever you add or remove a sending service, and rotate DKIM keys on a schedule.
  5. Send a test message to check that SPF, DKIM and DMARC all pass before each major campaign.
Check your own email in a minute. Send one email to a test address and see your SPF, DKIM, DMARC and spam score.
Test your email
Was this guide helpful?

Topics: Deliverability, Authentication, Best Practices, Technical