Deep Dive: SPF, DKIM, and DMARC

SPF and DKIM: Essential Email Authentication

Sender Policy Framework (SPF) and DomainKeys Identified Mail (DKIM) are critical standards for email authentication, designed to ensure that emails are sent from legitimate sources and remain unaltered during transit. SPF allows email senders to define which IP addresses are permitted to send mail on behalf of their domain, thus preventing email spoofing. DKIM adds a digital signature to the headers of an email, allowing the receiver to verify that the email has not been tampered with after it was sent.

Integration with Major Email Systems

Configuring SPF and DKIM is essential for organizations using platforms like Microsoft 365 and Google Workspace. Microsoft 365 uses an SPF TXT record to verify that the sender is authorized to send emails on behalf of the domain, and DKIM to ensure that the emails are not altered in transit. Google Workspace operates similarly, requiring the administrator to publish an SPF record and set up DKIM by generating a domain key that Google will use to create a digital signature.

Implementing SPF and DKIM in Popular Marketing and Email Systems

Systems like Salesforce, HubSpot, Mailchimp, Mailgun, Constant Contact, and Amazon SES emphasize the importance of properly configuring SPF and DKIM. For example, Salesforce recommends creating an SPF record that includes the Salesforce sending IPs, and setting up DKIM by generating a key pair that allows Salesforce to sign outbound emails. Similarly, Mailchimp offers tools to add their servers to your domain's SPF record and to create a DKIM key to authenticate your emails. These configurations help improve deliverability and ensure that marketing emails reach their intended recipients without being flagged as spam.

SPF and DKIM signing are crucial for these platforms because they significantly decrease the likelihood of email spoofing and phishing attacks, thereby protecting both the sender’s and the recipients’ reputation.

Understanding DMARC and its Operation

Domain-based Message Authentication, Reporting, and Conformance (DMARC) builds upon SPF and DKIM, providing additional instructions to the recipient’s mail server on how to handle emails that fail these checks. DMARC policies are defined through a DNS TXT record, specifying how to manage emails that do not authenticate.

DMARC uses two types of reports to help administrators understand how their emails are being handled: RUA (Aggregate Reports) and RUF (Forensic Reports). RUA reports provide a daily summary of all email activity for a domain, offering insights into which emails passed or failed SPF and DKIM checks. RUF reports are sent in real time and provide detailed information about specific emails that failed the DMARC checks, including the reasons for failure.

Setting up DMARC correctly is vital because it relies on the proper function of SPF and DKIM. If these are not accurately configured, even legitimate emails may be rejected or marked as spam, which can be detrimental to business communications. A misconfigured DMARC can lead to legitimate emails being blocked, affecting the reliability of email communications and potentially damaging the organization’s reputation.

Understanding SPF Notation and Configurations

Sender Policy Framework (SPF) is a standard used to prevent sender address forgery, specifying which mail servers are allowed to send email on behalf of your domain. An SPF record is written in DNS as a single string of text. It consists of mechanisms and qualifiers that define the mail servers authorized to send mail and instructions on how to handle mail that does or does not meet the criteria specified by those mechanisms.

SPF records might include several parts, each serving different functions. For instance, "include" is used to add another domain's SPF record to this domain's record. The "+" (pass), "-" (fail), "~" (soft fail), and "?" (neutral) qualifiers set the policy for handling mail depending on whether it passes the SPF check.

Qualifier Meaning Effect
+ Pass The server has permission to send emails on behalf of the domain.
- Fail The server does not have permission to send emails on behalf of the domain and the email should be rejected.
~ Soft Fail The server does not have permission to send but the email should be accepted but tagged.
? Neutral No policy is made; the server may or may not send emails on behalf of the domain.

Each SPF record begins with a version tag (v=spf1), followed by the list of allowed sending IPs, mechanisms for identifying additional sending IPs, and qualifiers that dictate the response to a failed check. For example, a typical SPF record might look like this: v=spf1 ip4:192.168.0.1 include:example.com -all. This configuration specifies that the IP address 192.168.0.1 and any servers allowed by example.com's SPF record can send emails on behalf of the domain, and emails from any other servers should be rejected.

DomainKeys Identified Mail (DKIM) is an email authentication method that uses cryptographic techniques to help ensure that an email was sent and authorized by the domain’s owner and that its content has not been altered in transit. A key element in the DKIM protocol is the use of selectors. A DKIM selector is a small piece of text used to point to a specific DKIM public key in the DNS. This allows a domain to have multiple keys published simultaneously, which can be useful for managing different keys for various email servers or administrative functions.

In DNS, DKIM records are typically published as TXT records. However, some systems use CNAME records to point to TXT records that contain the DKIM keys, which can simplify the management of DKIM keys, especially when using third-party services to send emails on behalf of a domain. The public key itself is stored in the DNS as a long string of encrypted characters. This key is part of the DKIM signature header in the outgoing emails, and it is used by receiving email systems to verify the signature. Due to the nature of DNS and the limitation of the TXT record, which can only store up to 255 characters, longer DKIM keys may need to be split into multiple strings within a single DNS record.

Here's a generic example of a DKIM TXT record:
selector._domainkey.example.com IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrZ2Kj..."
In this record, "selector" is the DKIM selector. v=DKIM1 declares the version of DKIM, k=rsa specifies the encryption algorithm (RSA), and p= contains the public key.

When an email is sent, the sending server generates a unique DKIM signature by using a private key to encrypt parts of the email header and body. This signature is included in the email headers when the email is sent. Upon receiving the email, the recipient server retrieves the DKIM public key from the sender’s DNS using the selector specified in the DKIM-Signature header. It then uses this key to decrypt the signature and compare it to a newly computed version. If the values match, it confirms that the email has not been tampered with since it was sent and that it was indeed sent by the owner of the domain, thereby validating the authenticity of the email.

Understanding DMARC Policies and Configuration

Domain-based Message Authentication, Reporting, and Conformance (DMARC) is an email authentication, policy, and reporting protocol that builds on SPF and DKIM protocols. It helps domain owners protect their domain from unauthorized use, commonly known as email spoofing. The DMARC record itself is a TXT record in the DNS system that starts with _dmarc. (e.g., _dmarc.example.com), indicating that it is a DMARC policy record and allowing receiving servers to recognize and apply the domain's DMARC policy.

The syntax of a DMARC record is straightforward but requires precise use of semicolons to separate tags and commas for multiple entries within a tag. Misuse of these can lead to parsing errors, making the DMARC policy ineffective.

Policy Description Effect
p=none No specific policy enforced. Emails that fail DMARC validation will be delivered but marked, and reports will be sent if requested.
p=quarantine Treat with suspicion. Emails that fail DMARC validation will be placed into the spam/junk folder.
p=reject Block delivery. Emails that fail DMARC validation will be rejected and not delivered to the recipient's inbox.

For example, a typical DMARC record might look like this: v=DMARC1; p=reject; rua=mailto:reports@example.com. This DMARC policy instructs receiving email servers to reject emails that fail DMARC checks, and to send aggregate reports of DMARC failures to the specified email address. Careful configuration of these policies is essential to ensure that legitimate emails are not mistakenly blocked or misrouted, especially when deploying a reject policy.






Home DNS Lookup Domain Profile Report DNS Explorer Instructions Domain Name System Email Security SPF, DKIM, DMARC About
close menu