Email authentication used to be a nice extra. It is now the entry fee. Major mailbox providers expect senders to prove that a message really came from the domain it claims, and they reject or junk mail that cannot. Three DNS records do that job: SPF, DKIM and DMARC. Each answers a different question, and they only protect you when all three agree. This guide shows how to set them up on your own domain, how to roll DMARC out without breaking legitimate mail, and how to confirm it works.
What each record does
SPF lists which servers may send mail for your domain. The receiving server checks whether the sending IP is on that list.
DKIM adds a cryptographic signature to each message. Your server signs with a private key, and receivers check the signature against a public key you publish in DNS. It proves the message was not altered and that it came from a system you control.
DMARC ties the two together. It tells receivers what to do when SPF and DKIM fail to line up with the visible From address, and where to send reports. Without it, the other two give receivers little to act on.
Step 1: publish an SPF record
An SPF record is a single TXT record at the root of the domain. A server that sends its own mail, plus a third-party service, might look like this:
example.com. IN TXT "v=spf1 ip4:203.0.113.10 include:_spf.google.com ~all"
The rules that cause the most trouble are simple. A domain must have only one SPF record, so combine every sender into one rather than adding a second. SPF allows at most ten DNS lookups in total, and every include and similar mechanism counts, so a long chain of services can break it silently. End with ~all while testing and move to -all once you are confident the list is complete.
Step 2: set up DKIM
On cPanel, the Email Deliverability tool generates and publishes DKIM for you when the domain uses the server's DNS. Plesk offers a DKIM option in the mail settings. If you run your own mail server with OpenDKIM, generate a key pair:
opendkim-genkey -b 2048 -d example.com -s mail
This creates a private key and a DNS record file. Publish the public key as a TXT record at the selector name, here mail._domainkey.example.com, and configure the mail server to sign outgoing messages with the private key. Use 2048-bit keys, and keep a separate selector for each sending system so you can rotate one without disturbing the rest.
Step 3: add DMARC in monitoring mode
Start with a policy that observes and does not act:
_dmarc.example.com. IN TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com"
The rua address receives daily aggregate reports from providers, listing which servers sent mail as your domain and whether they passed. Read them for a couple of weeks. They will reveal forgotten senders, such as a newsletter tool, a billing system or an old server, that need adding to SPF or DKIM.
Step 4: move to enforcement gradually
Once the reports show your legitimate mail passing, tighten the policy in stages: p=quarantine, optionally with pct=25 first so only a portion is affected, then p=quarantine fully, then p=reject. Each step should follow a period of watching the reports. Jumping straight to reject is how businesses discover that their invoicing system was never authenticated.
Step 5: set the supporting records
Reverse DNS matters as much as the three records. The IP address that sends your mail should have a PTR record matching a hostname that resolves back to the same IP. Receivers use it as a basic trust check, and many reject mail without it. Make sure the server's hostname and the name it announces when sending are consistent, as covered in why emails from your server end up in spam.
Test it
Look up the records directly:
dig +short TXT example.com
dig +short TXT mail._domainkey.example.com
dig +short TXT _dmarc.example.com
Then send a message to a Gmail address, open it, choose Show original, and look for SPF, DKIM and DMARC all marked PASS. A failure tells you which record to fix. If you are sending through WordPress, authenticated relay is usually more reliable than the web server's own mail function, as shown in how to configure remote SMTP on WordPress.
The rules from Gmail and Yahoo
Google's email sender guidelines require authentication for all senders. Those who send in bulk, around 5,000 messages a day or more to Gmail addresses, must have SPF, DKIM and a DMARC policy, keep spam complaint rates low, and offer one-click unsubscribe for marketing mail. Yahoo and Microsoft apply similar rules, and non-compliant mail can be rejected outright. Even small senders benefit, since unauthenticated mail increasingly goes to spam.
When mail still does not arrive
Authentication is necessary but not enough. Blacklisted IP addresses, a stuck queue or a compromised account can all stop delivery. If your server is clogged, see our guide to a stuck or frozen Exim queue, and if one host keeps refusing your mail, the Exim error in retry time not reached for any host is a common culprit.
If you want specialists to audit your records and mail logs, our email deliverability service finds the actual reason messages go missing, and you can contact us with your domain and mail server details.
Mail still landing in spam after setup?
We investigate authentication, DNS, reputation and mail logs to find why messages are not reaching inboxes, then fix them.



