Sub topic 9
Authenticating your sending domain
This chapter assumes you know how email is sent and received, what an email service provider (ESP) does, and what a DNS record is. It covers how receiving mail servers decide whether a message really comes from your domain.
Why authentication matters
Anyone can write any address in the From line of an email. Mailbox providers such as Gmail, Yahoo, and Outlook therefore check whether the sending server is allowed to use your domain. Messages that fail these checks are often sent to spam or rejected. This applies to all three email types: newsletters, promotions, and transactional messages.
Three standards work together:
| Standard | What it checks | Where it is published |
|---|---|---|
| SPF | The sending server's IP address is on your approved list | A TXT record on your domain |
| DKIM | The message carries a valid cryptographic signature | A public key in a TXT record, plus a signature added to each message |
| DMARC | SPF or DKIM passed and matches the visible From domain, plus what to do if not | A TXT record at `_dmarc` |
SPF: who may send
Sender Policy Framework (SPF) is a DNS record that lists the servers allowed to send mail for a domain. The receiving server compares the connecting IP address with that list.
An SPF record for a sending subdomain looks like this:
mail.example.com. TXT "v=spf1 include:_spf.esp.example.net -all"v=spf1marks the record as SPF.include:adds the servers your ESP publishes, so you do not list their IP addresses yourself.-alltells receivers to reject anything not listed.~allis a softer setting that marks it as suspicious.
A domain may have only one SPF record. If you use several services, merge them into one record. SPF also allows at most 10 DNS lookups, and each include: counts toward that limit.
DKIM: a signature on each message
DomainKeys Identified Mail (DKIM) adds a digital signature to the message headers. Your ESP signs each message with a private key. You publish the matching public key in DNS, and the receiver uses it to confirm that the message was not altered and that your domain approved it.
You normally do not write DKIM records by hand. Your ESP gives you one or more DNS records, often CNAME or TXT records, and you add them at your DNS host. The ESP then starts signing once it detects them.
DMARC: matching the From address and setting a policy
Domain-based Message Authentication, Reporting and Conformance (DMARC) ties the checks together. A message passes DMARC when SPF or DKIM passes and the domain that passed matches the domain in the visible From address. This match is called alignment.
DMARC also tells receivers what to do with failures and where to send reports:
_dmarc.mail.example.com. TXT "v=DMARC1; p=none; rua=mailto:[email protected]"p=noneis monitoring mode. Receivers take no action but send you reports.p=quarantineasks receivers to treat failures as suspicious.p=rejectasks receivers to refuse failures.rua=is the address that receives aggregate reports.
A safe rollout order
- Choose a sending subdomain such as
mail.example.com, so your main domain's reputation is protected. - Add the SPF include and the DKIM records your ESP provides.
- Send a test message and read its headers to confirm that SPF, DKIM, and DMARC show
pass. - Publish DMARC with
p=noneand read the reports for a few weeks. - Fix any legitimate sources that fail, such as a forgotten billing system.
- Move to
p=quarantine, thenp=reject, once the reports are clean.
Common errors
- Two SPF records. Receivers treat this as an error. Combine them into one.
- Too many lookups. More than 10 DNS lookups causes an SPF failure. Remove unused includes.
- Alignment failure. SPF can pass for the ESP's own bounce domain while the From domain is yours, so SPF does not align. Setting up DKIM with your own domain fixes this.
- Forwarding. Forwarded mail often breaks SPF. DKIM usually survives, which is why you want both.
- Never reading reports. A DMARC policy of
noneonly helps if someone reads the reports.
Exercise
Your SPF record passes, but DMARC still fails for a newsletter whose From address is [email protected]. The ESP sends from its own bounce domain, and DKIM is not set up. What is the likely cause and the fix?
Show answer
SPF passed for the ESP's bounce domain, which does not match the From domain, so there is no alignment. Set up DKIM with your own domain (the records the ESP gives you for mail.example.com). A DKIM signature from your domain aligns with the From address, and DMARC then passes.
Exercise
Why should you publish DMARC with p=none first, and what do you do before moving to a stricter policy?
Show answer
p=none takes no action on failures, so legitimate mail is not blocked while you learn what sends on your behalf. Read the rua aggregate reports, fix any legitimate sources that fail, then move to quarantine and later reject.