← All articles

How to Configure SPF, DKIM and DMARC for a Custom Domain

Read as Markdown

Learn how to configure SPF, DKIM, and DMARC records for your custom email domain to improve deliverability and prevent spoofing.

Mats Thorén··2026-11-04
How to Configure SPF, DKIM and DMARC for a Custom Domain

Setting up SPF, DKIM and DMARC for a custom domain ensures your emails arrive directly in the recipient's inbox rather than getting caught in spam filters. Major email providers such as Google and Yahoo enforce strict authentication requirements, rejecting or quarantining messages from domains that lack proper DNS validation records.

Configuring these three authentication standards establishes domain authority, verifies message integrity, and protects your domain against spoofing and phishing attacks. Here is how each protocol works and how to implement them step by step.

What SPF, DKIM and DMARC Do

Email authentication relies on three complementary layers:

  1. SPF (Sender Policy Framework) specifies which mail servers and IP addresses are authorized to send email on behalf of your domain. You publish an SPF record as a TXT record in your DNS settings. When a receiving server gets an email claiming to originate from your domain, it verifies whether the sender's IP address matches your authorized list.
  2. DKIM (DomainKeys Identified Mail) adds a cryptographic digital signature to the headers of outgoing emails. Your mail provider signs each email using a private key, while you publish the corresponding public key in your DNS records. The receiving server validates the signature against the public key, proving the email was not modified or tampered with in transit.
  3. DMARC (Domain-based Message Authentication, Reporting, and Conformance) unifies SPF and DKIM. It tells receiving servers what action to take (none, quarantine, or reject) if an incoming email fails SPF or DKIM checks, and allows you to receive aggregate delivery reports.

Step 1: Configure Your SPF Record

To configure SPF, log in to your DNS registrar or hosting provider control panel. Locate the DNS management section for your domain.

Check whether an existing SPF TXT record already exists. A domain should only ever have one SPF TXT record. Having multiple SPF records causes authentication to fail automatically.

If no record exists, create a new TXT record:

  • Host / Name: @ (or leave blank depending on your DNS host)
  • Type: TXT
  • Value: v=spf1 include:_spf.example.com ~all (replace _spf.example.com with your email service provider's specific SPF include statement)

The ~all mechanism specifies a soft fail, which flags unlisted servers without outright dropping legitimate messages during testing, whereas -all specifies a hard fail.

Step 2: Generate and Publish DKIM Records

Your email hosting provider generates the DKIM key pair. In your provider's admin console, locate the email domain authentication or DKIM settings.

Generate a new DKIM key. The provider will supply:

  • A selector name (such as s1 or mail)
  • A DNS record type (either CNAME or TXT)
  • The host name (typically selector._domainkey.yourdomain.com)
  • The target value containing the public key or provider target address

Copy these details into your DNS manager and create the corresponding record. Once saved, return to your email provider dashboard and click verify.

Step 3: Implement Your DMARC Policy

Once SPF and DKIM are active, configure DMARC to enforce domain protection. Create another TXT record in your DNS zone:

  • Host / Name: _dmarc
  • Type: TXT
  • Value: v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com

Starting with p=none is recommended for initial monitoring. This setting allows receiving servers to accept all messages while generating XML reports sent to your specified email address, letting you verify that legitimate sending services pass authentication before switching to p=quarantine or p=reject.

Step 4: Verify and Test DNS Propagation

DNS changes can take between a few minutes and 24 hours to propagate across global nameservers. Once configured, send a test email to a webmail inbox or use standard mail header analysis tools to verify that SPF, DKIM, and DMARC headers all return passing results. Proper email authentication maintains high deliverability and protects your sender reputation.

Related articles

Våra källor

Myndigheter och offentliga källor som rör ämnet:

Relaterade källor

Fördjupa dig vidare hos svenska medie- och referenskällor: