DNS Lookups for Email Deliverability Troubleshooting

Network

The DNS Records That Control Email Delivery

Four DNS record types determine whether your email reaches the inbox or spam folder:

Record Purpose
MX Points to the mail server that receives email
SPF Lists IPs authorised to send email for the domain
DKIM Cryptographic signature verifying message integrity
DMARC Policy for what to do when SPF/DKIM fail

Diagnosing Delivery Problems

Step 1 — Check MX Records

curl -X POST https://api.toolkitapi.io/v1/devtools/dns-lookup \
  -H "X-API-Key: $API_KEY" \
  -d '{"domain": "example.com", "type": "MX"}'

Missing MX records mean no mail server exists to receive your email.

Step 2 — Validate SPF

An SPF record is a TXT record starting with v=spf1. It should include every IP or service that sends on your behalf:

v=spf1 include:_spf.google.com include:sendgrid.net ~all

~all (softfail) is more permissive than -all (hardfail). Use -all for tighter security.

Step 3 — Confirm DKIM

DKIM records live at <selector>._domainkey.<domain>. If you don't know your selector, check your email provider's setup guide.

Step 4 — Review DMARC

v=DMARC1; p=reject; rua=mailto:[email protected]

p=reject means unauthenticated emails are rejected. Start with p=none for monitoring, then graduate to quarantine and reject.

Automated Monitoring

import httpx

DOMAINS = ["example.com", "mail.example.com"]

for domain in DOMAINS:
    for rtype in ["MX", "TXT", "DKIM"]:
        r = httpx.post(
            "https://api.toolkitapi.io/v1/devtools/dns-lookup",
            headers={"X-API-Key": API_KEY},
            json={"domain": domain, "type": rtype},
        )
        records = r.json().get("records", [])
        if not records:
            print(f"WARNING: No {rtype} record for {domain}")

Run this check daily to catch DNS changes before they affect delivery.

Try it out

Browse Tools →

More from the Blog