# A domain that doesn't send mail should say so too: SPF, DMARC, and null MX

> A domain that isn't used for email is the easiest to abuse for sending phishing under its name. Three DNS records can declare that the domain neither sends nor receives mail, giving receiving servers a basis for rejecting forged messages. This post covers why, which three records to set, how to add them in Cloudflare, and how to verify them.

Published 2026-11-22 · Updated 2026-11-22 · URL https://wizerdbache.com/en/notes/site-security-domain-email-spoofing/


When I ran the tests in [chapter 1](https://wizerdbache.com/en/notes/site-security-what-attackers-want/), one result surprised me: my domain had **no** anti-spoofing email records at all. Since the site doesn't send mail, I had never thought about it.

## Why set this up even without email

Cloudflare's documentation puts it plainly: without email-authentication records, **anyone can send email that looks like it came from your domain**. This is called domain spoofing.

Receiving servers decide whether a message really came from your domain by relying on what you declare in DNS. If you declare nothing, they have no basis for rejecting it. For a personal site, the likely case is someone using `@你的網域` to send phishing emails to your readers or friends, emails that look like you sent them.

## Three records

| Record | Where to add it | Value | Meaning |
|---|---|---|---|
| SPF | root domain, TXT | `v=spf1 -all` | no host is allowed to send mail for this domain |
| DMARC | `_dmarc`, TXT | `v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s` | messages that fail validation should be rejected by the receiver; subdomains too |
| Null MX | root domain, MX | priority `0`, mail server `.` | this domain does not receive mail |

Null MX is a record few people know. It has its own standard (RFC 7505): an MX with priority 0 and a host name of just `.` means “there is no mail server here.” Because `.` is not a valid host name, it won't be confused with a normal MX. Once a null MX is set, no other MX may exist.

**These three records only apply to a domain that neither sends nor receives mail at all.** If you use this domain's mailbox (including Google Workspace or mail forwarding), don't copy them; use the values your mail provider gives you instead.

## Setting up the three records in Cloudflare

1. Log into Cloudflare, select your domain, and in the left menu choose **DNS** → **Records**.
2. Click **Add record**.
3. First record (SPF): set **Type** to `TXT`, **Name** to `@`, **Content** to `v=spf1 -all`, then click **Save**.
4. Second record (DMARC): set **Type** to `TXT`, **Name** to `_dmarc`, **Content** to `v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s`, then click **Save**.
5. Third record (null MX): set **Type** to `MX`, **Name** to `@`, **Mail server** to `.`, **Priority** to `0`, then click **Save**.

Cloudflare also has an **Email** → **DMARC Management** page that lists your current email-authentication records and lets you set them there. Cloudflare's official guidance recommends setting them from that page; I added mine directly on the DNS page, so go by the field names you actually see.

## How to verify

In PowerShell, look up the records (replace `example.com` with your domain):

```powershell
nslookup -type=TXT example.com 1.1.1.1
```

```powershell
nslookup -type=TXT _dmarc.example.com 1.1.1.1
```

```powershell
nslookup -type=MX example.com 1.1.1.1
```

The first two should show the TXT content you just added (if the root domain has other TXT records, such as a site verification code, they are listed too). The third shows `MX preference = 0, mail exchanger = (root)` in Windows' nslookup; looking it up with `dig` shows `0 .`.

I checked right after adding them: SPF and DMARC showed up, but MX still didn't. The reason was DNS caching: 1.1.1.1 still remembered the earlier answer of “no MX.” Switching to another resolver (for example, Google's DNS-over-HTTPS) showed it. A “no” answer like that stays cached for a while (about 20 minutes in my case). If a lookup comes back empty right after you change something, wait a bit before checking again instead of changing it a second time.

## When you set up a mailbox later

Once you set up mail forwarding, Google Workspace, or any mail-sending service, **all three records must be changed first**:

- Delete the null MX and replace it with the MX your provider gives you.
- Change SPF to the value your provider gives (no longer `-all`, which rejects everyone).
- You can first change DMARC to `p=none` to observe for a while, confirm that your own mail passes validation, and then switch it back to `reject`.

If you don't change them first, the mail that gets rejected will be your own.

## Sources

- [Cloudflare DNS: Email records (Prevent domain spoofing)](https://developers.cloudflare.com/dns/manage-dns-records/how-to/email-records/) (Official documentation)
- [Cloudflare DNS: Create DNS records](https://developers.cloudflare.com/dns/manage-dns-records/how-to/create-dns-records/) (Official documentation)
- [Cloudflare DMARC Management: Security records](https://developers.cloudflare.com/dmarc-management/security-records/) (Official documentation)
- [RFC 7505: A "Null MX" No Service Resource Record](https://www.rfc-editor.org/rfc/rfc7505) (Standard)
