Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Enforce authentication with a DMARC policy


The Domain-based Message Authentication, Reporting, and Conformance (DMARC) policy directs how your ISP processes email messages that pass or fail email validation checks. DMARC provides the third factor for domain authentication.

To activate DMARC, a domain owner adds a DMARC record as a DNS TXT record(link takes you to an external page) on domain that sends email messages. This TXT record contains instructions on how to process email messages that fail authentication checks.

(information)

Limitations of DMARC

The scope of DMARC has limits. It doesn't verify content, sender identity, or verify the message integrity. It verifies the message sender, instructs the receiver how to route the message, and reports failed checks.


Prerequisites

prerequisites page anchor

To add a DMARC policy to your domain, you must understand the follow concepts:


Problem that DMARC solves

problem-that-dmarc-solves page anchor

To convince you that you're interacting with a trusted source, unauthorized senders might impersonate a specific email address. This act of impersonation practice is known as email spoofing. The purpose of spoofing can include getting sensitive data, taking over other online accounts, or stealing funds.

A spoofed email includes a forged From address, but not the From the recipient sees in their inbox. Email messages have their metadata which includes two From addresses:

Header FromEnvelope From
Property nameFromMAIL FROM or Return-Path
LocationEmail message header metadataSTMP envelope
NecessityRequiredRequired
Visible in email clientYesNo
PurposeShows who sent the email messageSpecifies where to send non-delivery reports (NDRs)
AuthenticatedNoYes with DKIM, SPF
Physical analogAddress on letterheadReturn address on envelope

Spoofing works as part of a phishing attack. Phishing seeks to get recipients to open email messages with links to malicious web sites or open damaging attachments.

While you could consider spoofing and phishing as a recipient's problem, an attacker that uses your email domain can damage your email reputation.

Two other standards, DomainKeys Identified Mail (DKIM) and Sender Policy Framework (SPF), authenticate email messages and senders, respectively. DKIM only validates the email address in the Envelope From.

To prevent email spoofing, DMARC policies determine what recipient email servers should do with email messages that pass and fail authentication checks.

Authenticate the email server: SPF

authenticate-the-email-server-spf page anchor

The SPF authenticates that the email server that sent the message can send messages on behalf of the domain. When the receiving email server gets the message, it requests the SPF record from the sender's DNS server. If the IP address or IP address range matches the IP address of the sending email server, the receiving email server accepts the incoming email message.

The SPF sets an allowlist that identifies which email servers can send email messages on behalf of a given domain. To implement SPF, you add a TXT record(link takes you to an external page) to your DNS server for your domain. The TXT record specifies the IP addresses that can send email for the related domain.

To perform an SPF check, the following steps take place.

  1. The receiving email server receives a message and checks the Envelope From (return-path).
  2. The receiving server retrieves the SPF record from the DNS records for the domain in the return-path.
  3. The receiving server checks the SPF record for all IP addresses approved to send email on behalf of the domain.
  4. If the SPF check passes, the receiving server considers the message sent from an approved sending server and continues processing the message.
  5. If the SPF check fails, the receiving server considers the message illegitimate. What happens after a failure depends on your DMARC policy.

To learn more about how SPF works, see Verify sending email servers with SPF.

Authenticate email message integrity: DKIM

authenticate-email-message-integrity-dkim page anchor

DKIM authenticates the integrity an email message using public-key encryption. This standard ensures that nothing tampered with the message in transit.

  1. The sending email server includes a signature in each email message's header. The signature includes an encrypted and hashed version of the email message header and body and instructions on how to decode the signature.
  2. After receiving the email message, the receiving email server requests the DKIM record from the domain's DNS provider. This includes the public key to decrypt the signature data.
  3. The receiving server then recreates the signature from the email message and compares it to the decrypted and decoded signature that got sent.
  4. If the signatures match, the DKIM check passes and the email message gets accepted.
  5. If the signatures don't match, the DKIM check fails. What happens after a failure depends on your DMARC policy.

To learn more about how DKIM works, see Verify senders with DKIM.

Route messages that fail checks: DMARC

route-messages-that-fail-checks-dmarc page anchor

While DKIM authenticates the email message and SPF authenticates the sending email server, neither tells the receiving server how to act on the results of these checks. DMARC provides that function. It tells the receiving email server what to do with email messages that pass or fail authentication.

(information)

Info

Twilio SendGrid offers additional DMARC enforcement and monitoring options in partnership with Valimail(link takes you to an external page).

DMARC doesn't work as an independent authentication protocol but as a framework for handling SPF and DKIM failures and reporting those failures to domain owners.

  • DMARC allows domain owners to specify what should happen if either or both SPF and DKIM checks fail.
    • Neither SPF nor DKIM provide this functionality on their own.
    • This means that without DMARC a sender can't determine what happens to a failed message.
  • A sender receives no feedback about SPF and DKIM failures without DMARC, so senders have little chance to combat or even understand the delivery trends of their domain, often called reputation monitoring.
  • SPF and DKIM are independent of each other, but neither provide thorough spoofing protection on their own.

DMARC builds upon SPF and DKIM. SPF and DKIM handle the domain-based message authentication part of DMARC.

DMARC adds reporting and conformance. Like SPF and DKIM, you implement DMARC through a TXT DNS resource record. Using this record, receiving email servers can fetch failure processing instructions from domain owners.

To check if an organization uses DMARC, see the DMARC.org(link takes you to an external page) FAQ entry.


To provide access to your DMARC policy, add it into the DNS registry of your domain as a TXT resource record(link takes you to an external page). The policy follows a format of a series of semicolon-separated tags:

Example DMARC DNS TXT record

example-dmarc-dns-txt-record page anchor
1
v=DMARC1;
2
p=(none|quarantine|reject);
3
rua=mailto:<email address>

The TXT record value must adhere to the following standards:

You can write your DMARC policy yourself or use a DMARC policy generator(link takes you to an external page).

A DMARC policy contains several semicolon-separated (;) tags. DMARC requires two tags: v (version) and p (policy).

The tag covers the policy applied to emails that fail the DMARC check.

TagMeaningValueAccepted valuesDefault value
vDMARC protocol versionDMARC1DMARC1
pPolicy for DMARC check failuresThe policy to apply to emails that fail the DMARC check. To collect DMARC reports, set to none.none, quarantine, reject
ruaRecipients of aggregate reportsA list of URIs expressed as email URIs(link takes you to an external page) of email service providers who should receive aggregate reports expressed as email URIs.mailto URIs
rufRecipients of forensic reportsA list of URIs expressed as email URIs(link takes you to an external page) of ISPs who should receive forensic reportsmailto URIs
spPolicy for subdomainsThe policy to apply to email from a subdomain of this domain that fail the DMARC check. As a domain owner, use this tag to publish a wildcard policy for all subdomains.
foReason to generate forensic reportIf both DKIM and SPF fail: 0
If either DKIM or SPF fail, 1
If only DKIM fail, d
If only SPF fail: s
0, 1, d, s
rfForensic report formatReporting format for forensic reports.
pctPercentage of failing emailsWhat percentage of failing email messages an ISPs should apply the DMARC policy. Requires p=q or p=r policy.Integer from 0 to 100
adkimAlignment mode for DKIM signaturesRelaxed (r) mode passes authenticated DKIM signing domains (d=) that share an Organizational Domain with an emails From domain. Strict (s`) mode requires an exact match.r, s
aspfAlignment mode for SPFRelaxed (r) mode passes authenticated SPF domains that share an Organizational Domain with an email's From domain. Strict (s) mode requires an exact match.r, sr
riReporting intervalHow often the server should send aggregate XML reports.Daily

The version, v=DMARC1, tells receiving servers that the DNS TXT record is a DMARC version 1 record.

The policy, p, can be one of three values, none, quarantine, or reject. Domain owners provide DMARC policies as instructions to a receiving email server on handling SPF and DKIM failures.

PolicyTypical actionEmail status
p=noneDeliver the message.Delivered
p=quarantineSend message to the spam folder.Recoverable
p=rejectDelete the message, bounce to the Envelope From address, or both.Deleted

Two tags manage SPF, aspf, and DKIM, adkim, alignment. These values determine how exact the domains in the From and the return-path email addresses must match for the check to pass. This tag accepts two values: r (relaxed) and s (strict).

  • Strict: Only return-path domains that match the domain set in the SPF or DKIM record exactly pass the check.
  • Relaxed: Any return-path domain that matches the parent domain set in the SPF or DKIM record pass the check. This allows CNAME addresses to pass a check.

The following table illustrates how alignment works:

Setting valueFrom domainreturn-path domainDMARC check result
r@example.com@mail.example.comPASS
r@mail.example.com@example.comPASS
r@mail.example.net@mail.example.comFAIL
s@example.com@mail.example.comFAIL
s@mail.example.com@example.comFAIL
s@mail.example.com@mail.example.comPASS

To specify different policies for subdomains, use the sp tag. Like the policy tag, p, the possible values for the sp tag are none, quarantine, and reject.

For example: You can apply a reject policy to your root domain and a quarantine policy for all its subdomains.

The percent tag, pct, specifies how many failing email messages follow your DMARC policy. The possible values are 1 through 100.

For example: If you set your policy to quarantine and your percent to 50, half of all failing email messages get quarantined.

You can adjust this tag value as you learn more about DMARC failures on your domain.


The reporting function of DMARC comes from two reports: an aggregation report and a forensics report.

DMARC aggregation file format and naming convention

dmarc-aggregation-file-format-and-naming-convention page anchor

Every 24 hours, inbox providers generate DMARC aggregate reports as compressed XML documents. It then attaches the reports to an email message as a ZIP archive. The email address you choose to receive reports must accept ZIP attachments. The files use the following filename format:

DMARC report filename format

dmarc-report-filename-format page anchor
reporter!policy-domain!begin-timestamp!end-timestamp.zip
(information)

Example of a DMARC aggregate report filename

Consider the following parameters:

  • The server that generates the DMARC report: google.com
  • The domain for which the server generated the report (your domain): example.com
  • Start date of the reporting period: Saturday, April 28, 2012 12:00:00 AM GMT
  • End date of the reporting period: Saturday, April 28, 2012 11:59:59 PM GMT
google.com!example.com!1335571200!1335657599.zip

Parse a DMARC aggregate report

parse-a-dmarc-aggregate-report page anchor

The following sample DMARC report includes one record with the results for two email messages. The SPF and DKIM auth_results report tag produce raw results, ignoring the s= alignment.

The XML file contains three main tags inside a feedback tag: record_metadata, policy_published, and record. The record tag repeats for each email source IP address.

The record_metadata tag contains the following tags:

TagContentPurpose
org_nameOrganization generating the reportConfirms which inbox provider observed the email traffic
emailContact address for the reporting organizationIdentifies contact point in the observing inbox provider
report_idUnique identifier for the reportServes as reference point for later identification
date_rangeTime period covered by the reportSets the timeframe for the results

The policy_published tag contains the following tags:

TagContentPurpose
domainDomain identified in the DMARC TXT recordIdentifies which domain set the DMARC policy
adkimAlignment mode for DKIM signaturesSame as the adkim= DMARC tag.
aspfAlignment mode for SPFSame as the aspf= DMARC tag.
pPolicy for DMARC check failuresSame as the p= DMARC tag.
spPolicy for subdomainsSame as the sp= DMARC tag.
pctPercentage of failing emailsSame as the pct= DMARC tag.

Each record tag contains the following tags:

TagContentPurpose
row
.source_ipIP address that sent the emailIdentifies email servers that sent the email messages
.countNumber of emails from that sourcePrioritize investigations by volume
row.policy_evaluated
.dispositionAction taken under DMARCShows how inbox provider handled the email message
.spfSPF authentication resultResult of SPF check for that source
.dkimDKIM authentication resultResult of DKIM check for that source
identifiers
.header_fromDomain in the visible From headerDomain against which DMARC evaluates alignment
auth_results.dkim
.domainDomain identified in the DKIM TXT recordDomain against which DKIM evaluates alignment
.resultDKIM authentication resultResult of DKIM check for that source
.selectorDKIM selector usedIdentifies which DKIM key has issues
auth_results.spf
.domainDomain identified in the SPF TXT recordDomain against which SPF evaluates alignment
.resultSPF authentication resultResult of SPF check for that source

DMARC and sender identity

dmarc-and-sender-identity page anchor

When sending email with a service provider such as Twilio SendGrid, you must authenticate a domain or verify a Single Sender.

(information)

What happens if you verify a sender identity using a gmail.com, yahoo.com, or a similar address?

Major mail providers, like Google, Microsoft, and others, protect their customers and prevent abuse using DMARC.

  • If you send a message from a Yahoo email address to a Gmail email address, Gmail checks Yahoo's SPF and DKIM records. These records verify the server and the integrity of the email.
  • Yahoo has SPF, DKIM, and DMARC policies. Yahoo's DNS records approve domains such as yahoo.com and the IP addresses Yahoo controls. Yahoo's approved domains and IP addresses don't include Twilio SendGrid domains and IP addresses.
  • When you send a message from a Yahoo email address to a Gmail email address using Twilio SendGrid, a Gmail server receives the message. As the return-path message header lists yahoo.com, Gmail looks up Yahoo's SPF and DKIM records.
  • The Gmail receiving server determines that a Twilio SendGrid IP address sent the message. Yahoo didn't sign the DKIM-Signature for the Twilio SendGrid message. Both SPF and DKIM checks fail. Gmail then follows Yahoo's DMARC failure policy.

No receiving email server can find out whether you used Twilio SendGrid for legitimate email marketing or you spoofed Yahoo's domain.

Twilio recommends authenticating a domain that you do control. The Twilio SendGrid domain authentication process provides CNAME records that you place on your own domain to approve the Twilio SendGrid IP addresses. To protect your domain's reputation, Twilio manages your SPF and DKIM records.


Inbox providers that enforce DMARC

inbox-providers-that-enforce-dmarc page anchor

Many inbox providers implement DMARC, including:

  • AOL
  • Gmail
  • Microsoft (Hotmail, MSN)
  • Outlook
  • Yahoo

Providers with DMARC policies might reject email with messages like:

521 5.2.1 : (DMARC) This message failed DMARC Evaluation and is being refused due to provided DMARC Policy

If bounce with one of these failure messages appears, Twilio SendGrid discarded and tracked it as a Block(link takes you to an external page). Adjust your From address field settings, and then try resending.


Get assistance interpreting DMARC reports

get-assistance-interpreting-dmarc-reports page anchor

Gaining insight from these XML documents can be difficult.

To collect the reports and present not the data but actionable insights, Twilio recommends using a DMARC report monitoring service.

Twilio SendGrid partners with Valimail. To leverage their DMARC monitoring and inbox provider alignment support, perform the following tasks:

  1. Set up an account through Valimail(link takes you to an external page).
  2. Add rua=mailto:dmarc_agg@vali.email in your DMARC record.