Short answer: To send email that gets delivered, your domain needs an MX record (for receiving), an SPF record and a DKIM record (to prove your mail is really yours), and a DMARC record (to tell receivers what to do when the proof fails). If you also send from a tool like a newsletter or app, give that tool its own subdomain.
Why these records exist
Email was built long before spam, so by default anyone can claim to be anyone. Receiving servers like Gmail use DNS records to check whether a message really came from the domain it claims. Here is the comparison. Think of a bank teller checking a withdrawal.
- SPF is the list of people allowed to make withdrawals on the account. The teller checks whether the sender is on the list.
- DKIM is the signature on the withdrawal slip. The teller checks that the signature matches the one on file and that the slip was not changed.
- DMARC is the bank's policy for what happens when the checks fail. Do nothing and watch, hold the slip for review, or refuse it outright.
Without those records, the teller has no way to tell a real withdrawal from a forgery, so the safe move is to treat the slip with suspicion. For email, that means the spam folder. With them, your messages look as trustworthy as they actually are.
The four records at a glance
The example below uses example.com and Google Workspace. Replace the domain with yours.
| Type | Host | Value | Purpose |
|---|---|---|---|
| MX | @ | Priority 1, smtp.google.com | Delivers incoming mail to Google |
| TXT | @ | v=spf1 include:_spf.google.com ~all | SPF: who may send for you |
| TXT | google._domainkey | v=DKIM1; k=rsa; p=YOUR_PUBLIC_KEY | DKIM: the signature key |
| TXT | _dmarc | v=DMARC1; p=none; rua=mailto:dmarc@example.com | DMARC: the policy and reports |
MX: where incoming mail goes
For Google Workspace the MX record is smtp.google.com at priority 1. You can read the full steps on the
Google Workspace guide.
SPF: who may send for you
SPF is a single TXT record at the root of your domain. The include:_spf.google.com part says Google's servers are allowed to
send for you, and ~all says to treat everyone else with suspicion. Two rules trip people up all the time:
- One SPF record per domain. If you need to authorize more senders, add more
include:parts to the same record. Two separate SPF records can make SPF fail. - Watch the lookup limit. SPF allows up to 10 DNS lookups in total, and every
include:can use some of them. Keep your list short.
DKIM: the signature
In the Google Admin console you generate a DKIM key for your domain (choose the 2048 bit key if it is offered). Google gives you a host name,
usually google._domainkey, and a long value that starts with v=DKIM1. Publish that as a TXT record exactly as shown,
then go back to the Admin console and start authentication. Do this for each domain you send from, and double check you copy the key for the
right domain.
DMARC: the policy
DMARC tells receivers what to do with mail that fails SPF and DKIM, and where to send reports. Start gently so you do not block your own legitimate mail by accident.
p=noneonly monitors and sends you reports. Start here and read the reports for a few weeks.p=quarantineasks receivers to treat failing mail as suspicious, which usually means spam.p=rejectasks receivers to refuse failing mail outright. This is the strongest protection.
v=DMARC1; p=none; rua=mailto:dmarc@example.com Moving from monitoring to enforcement is also what you need for showing your logo in the inbox, which we cover on the BIMI guide.
Sending from a tool? Use a subdomain
Newsletters, order receipts and app notifications usually go out through a sending service such as Mailgun, SendGrid or Amazon SES. A clean way
to set these up is on a subdomain, like mg.example.com, instead of your main domain. The comparison is a company vehicle. You would
not hand the keys to your own car to every delivery partner. You give them a separate van with its own plates, so if something goes wrong, your
personal car is not the one that gets pulled over.
In email terms, a subdomain keeps the reputation of bulk or automated mail separate from the mail your people send every day. If a campaign gets complaints, the subdomain takes the hit and your main inbox keeps its good name.
Here is what a Mailgun sending subdomain looks like. The exact values come from your Mailgun dashboard, so copy them from there.
| Type | Host | Value |
|---|---|---|
| MX | mg | Priority 10, mxa.mailgun.org and mxb.mailgun.org |
| TXT | mg | v=spf1 include:mailgun.org ~all |
| TXT | Your DKIM host, under _domainkey.mg | The DKIM value from Mailgun |
| CNAME | email.mg | mailgun.org (DNS only, not proxied) |
If your DNS lives on Cloudflare, set the CNAME and any record that points to a mail server to DNS only. Proxying them breaks mail.
What Gmail expects from senders
Google publishes email sender guidelines for mail going to personal Gmail accounts. In plain terms, every sender needs SPF or DKIM, and senders who send close to 5,000 messages or more a day to Gmail accounts are treated as bulk senders and need SPF, DKIM and DMARC all in place, with the message's From domain aligned to the SPF or DKIM domain. If you are anywhere near that volume, set all three up now. Even if you are nowhere near it, they are the easiest way to stay out of the spam folder.
How to test your setup
- Send a message from your domain to a personal Gmail account.
- Open the message, click the three dot menu, and choose Show original.
- Look at the top of the page for SPF, DKIM and DMARC. You want to see PASS on all three.
- If anything says fail or neutral, go back and check the record you published for that check.
Remember DNS takes time. New records can take a while to spread, and some resolvers hold on to old answers. If a record looks right and still fails, wait a bit and test again.