Tools · Explainer

Email authentication.

SPF, DKIM and DMARC with interactive demonstrations. Written in Simplified Technical English and updated for RFC 9989 (2026).

01Three names

Three names, one shown.

An email has three sender names. A mail program shows only one of these names to the reader.

The three names are:

  • Envelope sender (MAIL FROM). Mail servers use this name to send the email and to return errors.
  • Signing domain (d=). This is the domain that signs the email with DKIM.
  • From: domain. This is the name that the reader sees.

The sending server sets each name. The three names do not have to be the same.

In the demonstration below, do this step:

  1. Push show recipient view.

Only the From: line stays. The mail program does not show the other two names.

The SMTP protocol does not examine the From: line. Thus a sender can write any name in the From: line.

Three mechanisms protect the names:

  • SPF examines the envelope sender.
  • DKIM examines the signing domain.
  • DMARC connects the results of SPF and DKIM to the From: domain.

This article explains each mechanism in sequence.

02SPF

SPF: a list of permitted servers.

SPF is a DNS TXT record. The domain owner publishes the record. The record lists the servers that can send email for the domain.

When an email arrives, the receiving server does these steps:

  1. Read the domain in the envelope sender.
  2. Get the SPF record of that domain from DNS.
  3. Compare the IP address of the sending server with the list.

An SPF record can contain the include: mechanism. This mechanism adds the SPF record of a different domain. Most companies use external services to send email, for example Google or Mailchimp. Each service adds one include:. Each included record can contain more include: mechanisms.

The mechanisms include:, a, mx, exists: and redirect= each cause one DNS lookup. One SPF check can use a maximum of 10 DNS lookups.

In the demonstration below, do these steps:

  1. Move the services slider to the right.
  2. Look at the lookup budget bar.
1

Each new service uses more lookups. With 7 services, the record uses more than 10 lookups. SPF then gives the result permerror. Receiving servers then treat the record as incorrect.

The mechanism ip4: does not cause a DNS lookup. Thus some administrators replace include: mechanisms with the IP addresses of the services. This procedure is “SPF flattening”. It has a risk: when a service changes its IP addresses, the flattened record becomes incorrect. The record does not show an error.

SPF has two more limits:

  • When a server forwards an email, SPF fails. The forwarding server is not on the list of the original domain.
  • SPF examines only the envelope sender. SPF does not examine the From: domain.
03DKIM

DKIM: a signature on the content.

DKIM adds a cryptographic signature to the email. The sending server does these steps:

  1. Calculate a hash of the body (bh).
  2. Calculate a hash of the selected headers and the body hash.
  3. Sign the result with a private key (b).

b = Signkey( H( canon(headers) ∥ bh ) ),   bh = H( canon(body) )

The public key is in DNS at selector._domainkey.<d=>. The receiving server uses this key to verify the signature.

Mail servers sometimes change an email during transmission. For example, they change spaces or line breaks. A hash changes when one byte changes. Thus a small change can make the signature invalid.

DKIM has two canonicalization modes. Canonicalization changes the text to a standard form before the hash calculation:

  • simple keeps the text almost the same. Small changes make the signature invalid.
  • relaxed replaces a sequence of spaces with one space. It also changes header names to lowercase. Small changes to spaces do not make the signature invalid.

In the demonstration below, the left column shows the email as signed. The right column shows the email as received. Do these steps:

  1. Push extra whitespace.
  2. Push relaxed, then push simple. Compare the hash values.
  3. Push add list footer.
  4. Push relaxed, then push simple. Compare the hash values.
Canonicalization

Result of step 2: with relaxed, the signature stays valid. With simple, the signature becomes invalid. For this reason, most senders use relaxed/relaxed.

Result of step 4: the signature is invalid in the two modes. A mailing list adds text at the end of the body. This makes all DKIM signatures invalid. The last section of this article shows this problem again.

A valid signature shows only one fact: the domain in d= signed this content. An attacker can sign an email with a key for evil.com. That signature is also valid. Thus DKIM also does not examine the From: domain.

To check a real message, use the DKIM verifier. It shows the body hash and the signature result for each signature.

04DMARC

DMARC: connect the names to the From: domain.

Without DMARC, an attacker can do these steps:

  1. Rent a server.
  2. Add the server to the SPF record of evil.com.
  3. Make a DKIM key for evil.com.
  4. Send an email with From: billing@acme.com.

Result: SPF gives pass. DKIM gives pass. The receiving server does not detect the attack.

DMARC adds one rule: alignment. An email passes DMARC if one of these conditions is true:

  • SPF gives pass, and the envelope sender domain agrees with the From: domain.
  • DKIM gives pass, and the signing domain agrees with the From: domain.

There are two alignment modes:

  • Relaxed: the organizational domains must be the same. Example: mail.acme.com agrees with acme.com.
  • Strict: the full domain names must be the same.

In the demonstration below, you can select a sending server and the three names. The demonstration shows the DMARC result. Do these steps:

  1. Push legitimate. Make sure that DMARC gives pass.
  2. Push smart spoof. Compare the SPF and DKIM results with the alignment arrows.
  3. Push ESP default config.
  4. Push legitimate again. Then push strict.
Alignment

Result of step 2: SPF and DKIM give pass. But the two alignment arrows are red. The domain evil.com does not agree with acme.com. The attacker authenticated with the attacker’s own domain. DMARC detects this.

Result of step 3: a legitimate email service uses its own domains for SPF and DKIM. This email also fails DMARC. For this reason, an email service must sign with a DKIM key for your domain. You must publish this key in your DNS.

Result of step 4: in strict mode, mail.acme.com does not agree with acme.com. SPF alignment fails. DKIM alignment stays correct. Thus DMARC still gives pass.

05Policy

The DMARC policy and the DNS tree walk.

When DMARC fails, the receiving server reads the policy of the domain owner. The policy is a TXT record at _dmarc.<domain>. There are three policies:

  • p=none: deliver the email. Send reports to the domain owner.
  • p=quarantine: put the email in the spam folder.
  • p=reject: refuse the email during the SMTP session.

Many subdomains do not have a DMARC record. The receiving server must then find the record of a parent domain. RFC 7489 used a fixed list of public suffixes for this. RFC 9989 (May 2026) replaced RFC 7489.

RFC 9989 uses a DNS tree walk. The receiving server starts at the From: domain and moves up the DNS tree. It uses a maximum of 5 DNS queries. Top-level domains such as com have the tag psd=y (“public suffix domain”). The walk stops at this tag.

In the demonstration below, do these steps:

  1. Click a domain to add or remove its DMARC record.
  2. Push run tree walk.
  3. Look at the queries from the bottom to the top.

The first record that the walk finds gives the policy. The organizational domain is the domain with a record that is nearest to the root. It must not be a public suffix. Relaxed alignment uses this organizational domain.

Remove all records. Then run the walk again. The walk finds no record, and no DMARC policy applies. The receiving server then examines SPF and DKIM without alignment. For this reason, publish a DMARC record on all domains. This includes domains that do not send email.

06Procedure

The full procedure.

The demonstration below shows the full procedure for one email. The procedure has two authentication checks, one alignment rule and one policy. For each of the three scenarios, do these steps:

  1. Push the scenario button.
  2. Push next to go through the 6 steps.
1 / 6

The mailing list scenario shows a legitimate email that the receiving server refuses. There are three causes:

  1. The list changed the envelope sender. SPF gives pass, but for the domain of the list.
  2. The list added a footer. Thus the DKIM signature became invalid.
  3. The list did not change the From: domain. Thus no authenticated domain agrees with the From: domain.

The ARC protocol decreases this problem. A forwarding server adds its own signed record of the authentication results. The receiving server can use this record to make an exception.

07Limits

Limits of DMARC.

DMARC protects one item: the domain after the @ in the From: line. DMARC does not protect against these attacks:

  • A similar domain, for example acme-billing.com.
  • A display name such as “Acme Billing” with a different address.
  • A compromised mailbox at the correct domain. Email from this mailbox passes all checks.

Since 2024, large mailbox providers require authentication from bulk senders. Regulators also refer to DMARC. Thus SPF, DKIM and DMARC are now necessary for delivery to the inbox.