SPF, DKIM and DMARC explained: what to set up before your first email campaign.
Before the first email campaign, the sender's domain needs three DNS records: SPF, which identifies the servers authorised to send, DKIM, which signs messages with the domain's key, and DMARC, which checks whether the SPF or DKIM result applies to the domain shown in the “From” field. Since 1 February 2024, Gmail has required senders to have at least SPF or DKIM, and those sending close to 5,000 messages a day or more to personal Gmail accounts to have all three. These records are the foundation of good delivery, and the domain's reputation and the relevance of the message do the rest.
- Published
- Updated
- Reading time
- 8 min
- Category
- Deliverability
- Author
- DYNTRO team
Why does email need sender authentication?
SMTP, the protocol that servers use to pass email to each other, does not itself check whether the sender is who they claim to be. A message also has two sender addresses. The first is the envelope sender address (MAIL FROM, usually recorded in the Return-Path header), to which bounces return. The second is the address in the “From” field, which the recipient sees in their email client.
Microsoft's documentation for Microsoft 365 shows that these two addresses can belong to completely different domains. People who impersonate companies take advantage of this. Together, SPF, DKIM and DMARC close this gap. Each checks something different, which is why none of them replaces the others.
What does SPF do?
SPF (RFC 7208) is a TXT record in the domain's DNS. It lists the servers and services that may send email with an envelope sender address in that domain. The receiving server compares the sender's IP address with this list.
example.com. TXT "v=spf1 include:_spf.example.org ~all"
In this example, the domain example.com allows the servers of a service in the domain example.org to send its email. The ending ~all gives all other sources a “softfail” result, meaning suspicious, and -all gives a “fail” result. Microsoft recommends -all when the domain also has DKIM and DMARC. Before switching to -all, you need to know all the servers and services that send email from the domain.
With SPF, a few mistakes are easy to make:
- a domain may have only one SPF record; two records cause an error and SPF stops working;
- evaluating the record may require no more than 10 DNS lookups, e.g. through
include,aandmx; more is also an error; - a subdomain does not inherit the primary domain's record, so every domain and subdomain that sends email needs its own.
SPF also has weaknesses. It checks only the envelope sender address, not the address in the “From” field. It also stops working when another server forwards the message, because that server is not on the list.
What does DKIM do?
DKIM (RFC 6376) adds a digital signature to the message. The sending server signs important parts of the message with a private key, including the “From” field. The public key sits in DNS under a name made up of the selector and the domain. The receiving server uses it to check whether the signed content has changed on the way.
s1._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
Here, s1 is the selector. In the message signature, the domain is in the d= tag and the selector in the s= tag. RFC 6376 and RFC 8301, which updates it, require RSA keys of at least 1024 bits, and RFC 8301 recommends at least 2048 bits. Gmail requires the same minimum and recommends a 2048-bit key if the DNS provider supports it.
DKIM usually survives simple forwarding, because the signature travels with the message. It stops working when a server along the way changes the signed parts, e.g. a mailing list adds a footer or changes the subject. However, it has a gap similar to SPF: the signing domain does not have to be the domain in the “From” field. The DKIM standard does not require it.
What does DMARC do and what is domain alignment?
DMARC links the SPF and DKIM results to the address the recipient sees. It is described in RFC 9989 from May 2026, which replaced the earlier RFC 7489 and RFC 9091. A message passes DMARC when SPF or DKIM gives a positive result for a domain aligned with the domain in the “From” field.
Alignment has two modes. In relaxed mode, the default, the same organisational domain is enough, e.g. bounce.example.com and example.com. In strict mode, the domains must be identical. The domain owner sets the mode with the aspf and adkim tags.
That is why an “SPF pass” result on its own is not enough. If the sending service uses its own domain in the envelope, SPF passes for the service's domain, not for the domain in the “From” field. Without an aligned DKIM signature, such a message will not pass DMARC.
An example company sends a campaign from an address in the example.com domain through a sending service with the domain example.org. Example data.
| Check | Domain | Aligned with the “From” field? |
|---|---|---|
| “From” field | example.com | reference point |
| Envelope sender, SPF | bounce.example.org | no |
| Service signature, DKIM | d=example.org | no |
| Company signature, DKIM | d=example.com | yes |
DMARC passes thanks to the DKIM signature in the company's domain. If the service signed messages only with its own domain, SPF and DKIM would give a “pass” result and DMARC a “fail” result.
The DMARC record is a TXT record published at _dmarc. followed by the domain name:
_dmarc.example.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"
The p tag is the policy for messages that fail DMARC. With none, the domain owner does not ask for any change in handling. With quarantine, the owner considers such messages suspicious, and with reject, a clear sign that someone has used the domain without authorisation. The rua tag is the address for aggregate reports. Without it, receiving servers do not send these reports.
How do SPF, DKIM and DMARC work together?
| Mechanism | What it checks | Where the record is | Weakness on its own |
|---|---|---|---|
| SPF | whether the server may send with the envelope sender address | TXT in the domain | does not see the “From” field, breaks with forwarding |
| DKIM | whether the signed content is unchanged | TXT under selector._domainkey | the signing domain may differ from the one in the “From” field |
| DMARC | whether SPF or DKIM passed for the domain in the “From” field | TXT under _dmarc | without SPF and DKIM there is nothing to check |
Microsoft describes these standards as interdependent elements that only together give the best protection against spoofing and phishing.
What does Gmail require of senders?
Since 1 February 2024, Gmail has set requirements for everyone who sends email to Gmail accounts:
- SPF or DKIM for the sender's domain;
- valid forward and reverse DNS records (PTR) for the sender's domain or IP address;
- a TLS connection;
- a spam complaint rate in Postmaster Tools below 0.3%;
- a message format compliant with RFC 5322.
Senders who send close to 5,000 messages a day or more to personal Gmail accounts must additionally have SPF and DKIM, a DMARC record with a policy of at least none, and a domain in the “From” field aligned with the SPF or DKIM domain. Marketing and subscribed messages must also have one-click unsubscribe.
Even when a campaign is far from this threshold, it is worth meeting the requirements for bulk senders from the start. They are the same three DNS records, and the domain is then ready for a larger scale.
Which DMARC policy should you set at the start, and who reads the reports?
At the start, p=none with a report address in the rua tag. RFC 9989 describes such a record as monitoring mode: the domain owner already has working SPF and DKIM, collects aggregate reports, and message handling does not change. The reports show which servers send email using the domain and whether they pass SPF, DKIM and alignment.
The reports should go to a role-based mailbox, e.g. dmarc-reports@, that has an owner: a specific person who reviews them and knows what to do with the result. Not to a personal mailbox in the campaign domain that is used for sending. There, the reports get lost among recipients' replies, and after a staff change nobody reads them.
A quarantine or reject policy is the next step. It is set after analysing the reports, once it is known that all of the domain's email passes DMARC.
Will emails reach the inbox once the records are set up?
There is no such guarantee. RFC 9989 says that a “pass” result only confirms that the use of the domain in the “From” field of that message has been verified. The final decision belongs to the receiving server, which may reject the message or send it to quarantine despite a positive result. Microsoft states plainly that authentication does not guarantee delivery. It only protects against email going to the Junk Email folder solely because it lacks authentication. Google writes that authenticated messages are less likely to be rejected or marked as spam.
From there, the outcome depends on domain reputation, spam complaints, bounces and whether the message is relevant to the recipient. A targeted contact list and the reason for contact matter as much as the DNS records, as we write in the article on what B2B cold email is.
At DYNTRO, we set up SPF, DKIM and DMARC on separate campaign domains, and the client's company domain takes no part in sending.
Summary.
- SPF identifies the servers authorised to send, DKIM signs the message, and DMARC checks whether either of these results applies to the domain in the “From” field.
- An “SPF pass” result on its own is not enough. Domain alignment is what counts.
- Since February 2024, Gmail has required SPF or DKIM from all senders, and SPF, DKIM and DMARC from those sending close to 5,000 messages a day or more to personal Gmail accounts.
- At the start,
p=nonewith reports going to a role-based mailbox that has an owner. - The records are the foundation of good delivery, and domain reputation and message relevance do the rest.
We run email and LinkedIn campaigns to decision-makers, from data and domains to replies, while your salespeople focus only on conversations. See the service: B2B email campaigns.
Book a callQuestions and answers.
Is SPF alone enough?
No. Gmail requires all senders to have at least SPF or DKIM, but SPF on its own checks only the envelope sender address, not the domain in the “From” field that the recipient sees. It also stops working when another server forwards the message. Senders who send close to 5,000 messages a day or more to personal Gmail accounts must have SPF, DKIM and DMARC. The simplest approach is to set up all three from the start.
Which DMARC policy should you set at the start?
A p=none policy with a report address in the rua tag. Such a policy does not change how messages are handled, and the aggregate reports show which servers send email using the domain and whether they pass SPF, DKIM and alignment. The reports should go to a role-based mailbox that has an owner. A quarantine or reject policy is set only after the reports have been analysed.
Sources.
- RFC 7208, Sender Policy Framework (SPF)datatracker.ietf.org
- RFC 6376, DomainKeys Identified Mail (DKIM) Signaturesdatatracker.ietf.org
- RFC 9989, Domain-Based Message Authentication, Reporting, and Conformance (DMARC)datatracker.ietf.org
- Google, Email sender guidelinessupport.google.com
- Microsoft Learn, How email authentication works in Microsoft 365learn.microsoft.com
- Microsoft Learn, Set up SPF to identify valid email sources for your Microsoft 365 domainlearn.microsoft.com
- RFC 8301, Cryptographic Algorithm and Key Usage Update to DomainKeys Identified Mail (DKIM)datatracker.ietf.org
- RFC 7960, Interoperability Issues between DMARC and Indirect Email Flowsdatatracker.ietf.org
