Protect a domain that sends no email from spoofing
A domain without mail records can still be impersonated. Three DNS records tell receiving servers to reject mail that claims to come from it.
What this guide covers
A domain that is used for a website or a homelab, but never for email, can still appear as the sender of somebody else’s message. This guide adds three DNS records which state that the domain sends and accepts no mail, so that mail servers reject messages that claim to come from it.
- For: anyone who owns a domain that sends no email, such as a personal site, a homelab domain, or a domain registered only to protect a name.
- Result: mail servers that check these records are told to reject every message that uses the domain, or any of its subdomains, as the sender.
- Time: about ten minutes, plus the time the DNS change takes to become visible.
The records were tested on a live domain hosted at Cloudflare DNS. The commands use
example.com; replace it with the domain to protect.
Why a domain without mail records is at risk
Email was designed without a way to prove who sent a message. It works much like a paper letter, which names its sender in two places:
- The envelope has a return address. The postal service uses it when the letter cannot be delivered. The reader usually throws the envelope away.
- The letter inside has a letterhead. That is the sender the reader sees.
Nobody checks either one. Anyone can write a false return address on an envelope and print another company’s letterhead on the letter.
An email has the same two parts. The envelope sender is the return address: mail servers use it during delivery and report failures to it. The From header is the letterhead: the address that the reader’s mail program displays. A sender can write any domain into both. Using someone else’s domain there is called spoofing.
The owner of a domain can do something about it through DNS, the public directory in which every domain lists its settings. Three kinds of DNS record deal with mail, and other mail servers look them up:
| Record | What it tells other mail servers |
|---|---|
| SPF (Sender Policy Framework) | Which servers may send mail for the domain. It is checked against the envelope sender. |
| DMARC (Domain-based Message Authentication, Reporting and Conformance) | What to do with a message that fails the checks. It looks at the From header, the address the reader sees. |
| MX (mail exchange) | Which servers accept mail addressed to the domain. |
The diagram shows a spoofed message that arrives after the owner of example.com has
published these records. The spoofer uses a domain of their own on the envelope and
example.com in the From header.
A domain that publishes none of these records gives the mail server nothing to check. The spoofed message is treated like any other mail and judged by its content. That is also true for a domain that has never sent an email, and such a domain is a convenient choice for a spoofer: nobody is watching what is sent in its name.
Before you start
- Access to the domain’s DNS records. They are managed in the dashboard of the DNS provider, which is often the company the domain was registered with.
dig, a command-line tool that looks up DNS records. It is included in macOS. On Linux it is in the packagednsutils(Debian, Ubuntu),bind-utils(Fedora) orbind(Arch Linux).- Certainty that nothing sends mail as the domain. These records make mail servers reject
all of its mail, legitimate or not. Check for:
- mail records that already exist (Step 1 shows them)
- applications that send notifications from an address at the domain, such as password resets, alerts and contact forms
- a mail provider, newsletter service or help desk that was set up with the domain
If something does send mail as the domain, stop here. That domain needs records that name its real senders, not the ones in this guide.
Step 1: Check the current records
Ask DNS for the three records. SPF and DMARC are both stored as TXT records, a record type that holds plain text.
# MX: the servers that accept mail for the domaindig +short MX example.com
# TXT records of the domain itself: an SPF record would be one of themdig +short TXT example.com
# TXT record at the name _dmarc: the DMARC recorddig +short TXT _dmarc.example.comOn an unprotected domain, the first and third commands print nothing. The second prints
nothing, or TXT records that have nothing to do with mail, such as the verification codes
that some services ask for. What matters is that no line starts with v=spf1, which marks
an SPF record.
If a mail record already exists (an MX record that names a server, an SPF record that
contains include: or ip4:, or any DMARC record), something was set up to handle mail
for the domain. Find out what it is before replacing anything.
Step 2: Add the three records
Open the domain’s DNS records in the dashboard of the DNS provider and add these three:
| Type | Name | Content |
|---|---|---|
| TXT | @ |
v=spf1 -all |
| TXT | _dmarc |
v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s |
| MX | @ |
Priority 0, mail server . (a single dot) |
Notes on entering them:
@stands for the domain itself. Some providers expect the full domain name or an empty field instead._dmarcis the fixed name at which mail servers look for a DMARC record.- A domain may have only one SPF record. If one exists, replace it. Two SPF records cause an error at the mail server instead of a clear result.
- The MX record with the single dot must be the only MX record. Delete any other.
The next three sections explain what each record means. To continue without the background, go to Step 3.
SPF: no server may send
An SPF record is the domain’s list of servers that may send its mail. A mail server that receives a message compares the server that delivered it with this list.
In v=spf1 -all, the first part marks the text as an SPF record. -all means “every
server that is not on the list fails the check”. The list is empty, so every server fails.
The SPF standard gives exactly this record for a domain that sends no mail.
Many SPF records end in ~all instead. That softer form is meant for domains that are
still finding out which servers send their mail. A domain with no senders has nothing to
find out, so the strict form is correct.
An SPF record applies only to the exact name it is published at. A subdomain such as
www.example.com, or an invented one such as billing.example.com, is not covered by the
record at example.com. The DMARC record takes care of those.
DMARC: reject what fails
SPF alone leaves a gap. It checks the envelope sender, and the reader never sees that
address. As in the diagram above, a spoofer can use a domain of their own on the envelope,
pass the SPF check for that domain, and still show ceo@example.com in the From header.
DMARC closes the gap in two ways. A check only counts if it passes for the same domain that appears in the From header (the standard calls this alignment). And the record tells the mail server what to do with a message that fails. With the records from this guide, no message can pass:
| Envelope sender the spoofer uses | SPF result | DMARC result |
|---|---|---|
example.com |
Fail: the list of allowed servers is empty | Fail |
| A domain the spoofer controls | Pass, but for the spoofer’s domain | Fail: the pass is not for the domain in the From header |
DMARC also accepts a second kind of proof, DKIM (DomainKeys Identified Mail). It is a
digital signature that the sending server adds to a message, and it is checked with a key
that the domain publishes in DNS. example.com publishes no key, so a spoofer cannot
produce a valid signature for it.
The DMARC record is a list of settings separated by semicolons:
| Setting | Meaning |
|---|---|
v=DMARC1 |
Marks the text as a DMARC record. It must come first. |
p=reject |
The policy: reject mail that fails. The weaker values are quarantine (treat it as suspicious) and none (no preference). |
sp=reject |
The policy for subdomains, whether they exist or not. Subdomains would follow p anyway. Stating it keeps them protected if p is ever relaxed. |
adkim=s, aspf=s |
Strict matching: the domain that passed the check must be exactly the domain in the From header. The default also accepts its subdomains. Nothing sends mail here, so the stricter rule costs nothing. |
Subdomains need no records of their own. A mail server that finds no DMARC record for
www.example.com looks for one at example.com and applies its sp setting.
The policy is a request. The DMARC standard leaves the final decision about each message
to the mail server that receives it, so p=reject makes rejection the expected result, not
a guaranteed one.
Null MX: no mail accepted
An MX record tells other mail servers where to deliver mail for a domain. This record is about mail sent to the domain, not mail sent in its name.
Without any MX record, a sending server falls back to the address that the domain’s website uses and tries to deliver the mail there. No mail server answers at that address, so the sender keeps trying. According to the null MX standard, this typically goes on for a week before the person who wrote the message is told that it failed.
An MX record with the priority 0 and a single dot as the server is called a null MX. It
states that the domain accepts no mail. Delivery fails at once with a clear error, so a
person who mistyped an address finds out immediately.
The null MX also supports the other two records. Many mail servers reject mail whose return address cannot receive mail, and the null MX marks every address at the domain as such.
Some DNS providers do not accept a single dot as a mail server. Cloudflare DNS does. If the provider refuses it, leave this record out: SPF and DMARC provide the protection against spoofing.
Step 3: Verify
Run the same three queries as in Step 1:
dig +short MX example.comdig +short TXT example.comdig +short TXT _dmarc.example.com0 ."v=spf1 -all""v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s"The second query also lists any other TXT records of the domain.
DNS answers are cached: a DNS server that has looked up a record keeps the answer for a while, so it can be out of date right after a change. To rule that out, ask one of the domain’s authoritative nameservers. These are the servers at the DNS provider that hold the original records.
# Find the domain's nameservers and keep the first onens=$(dig +short NS example.com | head -n 1)
# Ask that server directlydig +noall +answer MX example.com @"$ns"dig +noall +answer TXT _dmarc.example.com @"$ns"example.com. 300 IN MX 0 ._dmarc.example.com. 300 IN TXT "v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s"To see what a protected domain looks like before changing anything, run the commands
exactly as written. example.com is reserved for documentation, and IANA, which operates
it, publishes the same three records for it. Its DMARC record is written without spaces,
which is equally valid.
For several domains, a loop prints the three answers for each:
for domain in example.com example.net example.org; do echo "== $domain" dig +short MX "$domain" dig +short TXT "$domain" | grep -i 'v=spf1' dig +short TXT "_dmarc.$domain"doneTroubleshooting
The queries still return nothing after the change. DNS servers also cache the answer “this record does not exist”. The check in Step 1 produced exactly that answer, and it can stay in the cache for a while: 30 minutes at the provider used for this guide. Ask an authoritative nameserver as in Step 3, or wait.
A public DNS server gives a different answer than expected. Some networks redirect all
DNS queries to their own DNS server, for example to filter ads. A query such as
dig @1.1.1.1 is then answered locally as well. A query over HTTPS is not redirected:
curl -s -H 'accept: application/dns-json' \ 'https://cloudflare-dns.com/dns-query?name=_dmarc.example.com&type=TXT'The record appears in the Answer field of the reply.
dig shows two lines that start with v=spf1. An older SPF record is still in place.
Delete it. With two SPF records, the SPF check ends in an error instead of a fail.
Legitimate mail from the domain is rejected. Something does send mail as the domain. Change the records as described in the next section.
If the domain sends mail later
The records have to change before the first message is sent. The mail provider’s setup instructions give the exact values.
- MX: remove the null MX and add the provider’s MX records. A null MX cannot exist next to other MX records, and mail servers may reject mail from a domain that publishes one.
- SPF: replace
v=spf1 -allwith the SPF record that the provider gives. - DKIM: add the provider’s DKIM key, so that its servers can sign the domain’s mail.
- DMARC: the record can stay. If the provider sends or signs from a subdomain, the
strict matching fails: remove
adkim=sandaspf=s.
Optional additions
Neither of these is needed for the protection, and neither was part of the tested setup.
- Reports. With an added
rua=setting in the DMARC record, mail servers send a daily summary of the mail they saw that claimed to come from the domain. That shows spoofing attempts. The reports need a mailbox, and this domain has none. A mailbox at another domain works only after that domain publishes a record that accepts the reports. Services that process DMARC reports set this up. - A wildcard DKIM record. Some guidance adds a TXT record with the name
*._domainkeyand the contentv=DKIM1; p=, which marks every possible DKIM key as revoked. The result is the same without it: no key is published, so no signature for the domain can be valid.
Further reading
- RFC 7208: SPF. Section 10.1.2 gives the record for a domain that sends no mail.
- RFC 9989: DMARC. Published in May 2026, it replaces RFC 7489.
- RFC 9990: DMARC reports, including the record that accepts reports for another domain.
- RFC 7505: null MX.
- Protect domains that do not send email: UK government guidance, with the wildcard DKIM record.