← Back to Research

DMARC, SPF, and DKIM: The Email Security Trifecta Your Domain Needs

In our recent scan of 50 companies, 100% of those that received a Grade F were missing DMARC records entirely. Not a single one had configured this free, standard protection against email spoofing. This finding was so consistent that it became the single most reliable predictor of an organization's overall security posture: if you do not have DMARC, you probably do not have much else either.

Email authentication is not optional. Domain spoofing is the foundation of business email compromise (BEC), phishing campaigns, and brand impersonation attacks. The FBI's IC3 reported over $2.9 billion in BEC losses in 2023 alone. Three DNS records -- SPF, DKIM, and DMARC -- working together can prevent the vast majority of these attacks. They are free to implement, take less than an afternoon to configure, and require no software installation.

This guide walks through what each protocol does, how to set them up correctly, common mistakes to avoid, and how to test your configuration.

Why All Three Are Needed Together

SPF, DKIM, and DMARC are complementary protocols that each address a different aspect of email authentication. None of them is sufficient alone:

Without DMARC, SPF and DKIM operate independently with no enforcement policy. A receiving server might check SPF and DKIM, but if both fail, the default action is usually to deliver the email anyway (possibly with a spam score adjustment). DMARC changes this by providing an explicit policy: reject the email, quarantine it, or at minimum report it.

The alignment check is critical. An attacker can send email using their own server (passing their own SPF) and their own DKIM key, but set the visible "From" header to your domain. Without DMARC's alignment requirement, this email passes both SPF and DKIM -- just not for your domain. DMARC catches this by requiring that the SPF or DKIM domain matches the visible "From" domain.

Step 1: Set Up SPF

SPF is a DNS TXT record on your domain that lists all servers authorized to send email on your behalf.

Basic SPF Record

yourdomain.com TXT "v=spf1 include:_spf.google.com include:sendgrid.net -all"

Breaking this down:

Common SPF Mistakes

Too many DNS lookups. The SPF specification limits records to 10 DNS lookups. Each include:, a:, mx:, and redirect: mechanism counts as a lookup, and nested includes count against your total. Organizations using multiple SaaS tools (marketing email, transactional email, CRM, help desk) routinely exceed this limit. When the limit is exceeded, SPF fails entirely -- meaning no email passes SPF authentication.

Check your lookup count:

# Use mxtoolbox.com SPF lookup, or:
dig TXT yourdomain.com +short | grep spf

If you are over 10 lookups, consolidate by using IP ranges (ip4:) instead of includes, or use an SPF flattening service.

Using ~all (soft fail) instead of -all (hard fail). Soft fail tells receivers "this might not be legitimate, but do not reject it." This provides minimal protection. Use -all once you have confirmed all legitimate senders are included in your SPF record.

Forgetting to include all sending sources. Audit every service that sends email using your domain: marketing platforms, transactional email, help desk, CRM, internal applications, and automated systems. A single missing source will cause legitimate email to fail SPF.

Step 2: Set Up DKIM

DKIM requires generating a public/private key pair. The public key is published as a DNS record; the private key is configured on your mail server or email provider.

Generating DKIM Keys

Most email providers generate DKIM keys for you. For Google Workspace, Postmark, SendGrid, and other hosted providers, follow their documentation to generate the key and they will provide the DNS record to publish.

For self-hosted mail servers, generate a key pair with OpenSSL:

# Generate a 2048-bit RSA key pair:
openssl genrsa -out dkim_private.pem 2048
openssl rsa -in dkim_private.pem -pubout -out dkim_public.pem

# Extract the public key for DNS (remove headers and newlines):
grep -v '^-' dkim_public.pem | tr -d '\n'

Publishing the DKIM DNS Record

selector._domainkey.yourdomain.com TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."

The selector is a name you choose (like google or s1) that identifies which key to use. You can have multiple DKIM selectors for different sending services.

Common DKIM Mistakes

Step 3: Set Up DMARC

DMARC is the enforcement layer. It tells receiving servers what to do when SPF or DKIM fails and sends you reports about authentication results.

DMARC Policy Progression

Deploy DMARC in stages to avoid disrupting legitimate email:

Stage 1: Monitor (p=none)

_dmarc.yourdomain.com TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com; ruf=mailto:dmarc-forensics@yourdomain.com; fo=1"

This tells receivers to send aggregate reports (rua) and forensic reports (ruf) to your email addresses but take no action on failing emails. Run in this mode for 2-4 weeks and review the reports to identify all legitimate sending sources.

Stage 2: Quarantine (p=quarantine)

_dmarc.yourdomain.com TXT "v=DMARC1; p=quarantine; pct=25; rua=mailto:dmarc-reports@yourdomain.com"

Start quarantining failing emails. The pct=25 directive applies the policy to only 25% of failing messages, letting you gradually increase coverage. Raise to 50%, then 75%, then 100% over several weeks as you confirm no legitimate email is affected.

Stage 3: Reject (p=reject)

_dmarc.yourdomain.com TXT "v=DMARC1; p=reject; rua=mailto:dmarc-reports@yourdomain.com; adkim=s; aspf=s"

Full enforcement. Emails that fail DMARC alignment are rejected outright. The adkim=s and aspf=s directives require strict alignment (exact domain match, not just organizational domain), providing the strongest protection.

Common DMARC Mistakes

Testing Your Configuration

After deploying all three records, verify them with these free tools:

MXToolbox

# Check SPF:
https://mxtoolbox.com/spf.aspx

# Check DKIM (need to know your selector):
https://mxtoolbox.com/dkim.aspx

# Check DMARC:
https://mxtoolbox.com/dmarc.aspx

Command-Line Verification

# Check SPF record:
dig TXT yourdomain.com +short | grep spf

# Check DKIM record (replace 'google' with your selector):
dig TXT google._domainkey.yourdomain.com +short

# Check DMARC record:
dig TXT _dmarc.yourdomain.com +short

Send a Test Email

Send an email to check-auth@verifier.port25.com (a free service by Port25). You will receive an automated reply showing whether your email passed SPF, DKIM, and DMARC checks. Google's Gmail also shows authentication results -- click the three dots on any received email and select "Show original" to see SPF, DKIM, and DMARC pass/fail status.

Why This Matters: The Data

In our scan of 50 companies, the correlation between missing DMARC and overall security posture was stark:

DMARC configuration is a reliable proxy for security maturity because it requires understanding your email infrastructure, auditing all sending sources, and progressively tightening policy -- the same systematic approach that characterizes good security programs in general.

An attacker performing reconnaissance on your domain can check your DMARC record in seconds. If it is missing, they know two things: (1) they can spoof your domain for phishing, and (2) your security program is likely immature, making you a softer target for other attacks.

Check your email security in minutes

Our free scan checks DMARC, SPF, DKIM, and dozens of other misconfigurations visible from the internet.

Scan Your Domain Free

Sources