In short
SPF lists which servers may send email for your domain, DKIM proves with a digital signature that a message was not altered in transit, and DMARC tells receivers what to do when those checks fail. All three are added to DNS as TXT records. Set up SPF and DKIM first, then start DMARC at p=none, watch the reports, and move gradually to quarantine and reject.
In this guide
- What Do SPF, DKIM, and DMARC Do?
- Step 1: Create Your SPF Record
- Step 2: Create Your DKIM Record
- Step 3: Create Your DMARC Record
- Rolling Out DMARC Gradually: none → quarantine → reject
- How to Verify Your Records
- Example: A Complete Record Set
- Protect Domains That Don't Send Email, Too
- Extra Checks If You Run Your Own Mail Server
- Next Step: Choose the Right Infrastructure
If your business email lands in spam or Gmail shows a "this sender is unverified" warning, the cause is most likely missing or broken SPF, DKIM, and DMARC records. All three are added to your domain's DNS zone as TXT records, and they are the standard way to tell receiving servers "this message really comes from me." Below you'll find what each record does, the correct syntax, how to tighten your DMARC policy safely, and how to test your records, step by step.
What Do SPF, DKIM, and DMARC Do?
The three records don't replace each other; each one answers a different question:
| Record | Question it answers | Where it lives in DNS |
|---|---|---|
| SPF (Sender Policy Framework) | Is this IP address allowed to send email for my domain? | alanadiniz.com TXT |
| DKIM (DomainKeys Identified Mail) | Was the message changed after it was sent, and does the signature belong to my domain? | selector._domainkey.alanadiniz.com TXT |
| DMARC (Domain-based Message Authentication, Reporting and Conformance) | What should happen if SPF/DKIM fail, and where should reports go? | _dmarc.alanadiniz.com TXT |
The key DMARC concept is alignment: the domain in the From: address the recipient sees must match either the envelope sender (Return-Path) that SPF checks or the d= domain in the DKIM signature. Even if SPF passes, DMARC fails when the domains don't match. If DNS record types are new to you, start with our DNS records guide.
Step 1: Create Your SPF Record
An SPF record is a single TXT record added at your domain's root (@). The basic structure looks like this:
v=spf1 mx a include:_spf.saglayici.com ip4:203.0.113.10 ~all
v=spf1: Marks the record as SPF. It always comes first.mxanda: Authorize the servers in your domain's MX and A records.include:: Pulls in another service's SPF list (newsletter tool, CRM, email provider).ip4:/ip6:: Authorizes a specific IP address or range.~all(softfail) or-all(fail): Defines how any source not on the list is treated.
Common mistakes:
- Adding two separate SPF records. A domain can have only one
v=spf1record; a second one invalidates both (permerror). When you add a new service, edit the existing record instead. - Exceeding the 10 DNS lookup limit. The
include,a,mx,exists, andredirectmechanisms can trigger at most 10 DNS lookups in total. Remove includes for services you no longer use. - Using
+all. This lets every server in the world send mail as you. Never use it.
If you use email hosting, enter the SPF value your provider gives you exactly as provided. Sunucu Atlas business email hosting plans come with SPF and DKIM support ready to go; all you need to do is make sure the records are correct in your domain's DNS.
Step 2: Create Your DKIM Record
DKIM adds a signature, made with a private key, to the header of every outgoing message. The receiving server verifies that signature using the public key you publish in DNS. The key pair is generated on the mail server; you only put the public key in DNS.
- Open the DKIM section in your email control panel or on your server and generate a key for your domain. Choose a 2048-bit RSA key if possible.
- The panel gives you a selector name (e.g.,
default,dkim,mail) and a TXT value. - Add a TXT record named
selector._domainkeyto your DNS zone. The value looks like this:
dkim._domainkey.alanadiniz.com. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
2048-bit keys exceed the 255-character TXT string limit. Most DNS panels split them automatically; if you enter the value by hand, you can break it into several quoted strings, and receiving servers join the parts back together. When copying the value, make sure no spaces or line breaks slip in; a single missing character breaks the signature.
A note for teams running their own mail server: on the mail server with mailcow preinstalled, DKIM keys are generated per domain from the configuration section of the admin interface, and the TXT value can be copied directly.
Step 3: Create Your DMARC Record
The DMARC record goes on the _dmarc subdomain. Your first record should always be in monitoring mode:
_dmarc.alanadiniz.com. 3600 IN TXT "v=DMARC1; p=none; rua=mailto:dmarc-rapor@alanadiniz.com; fo=1"
| Tag | Meaning |
|---|---|
p | Policy: none (monitor only), quarantine (send to spam/quarantine), reject (reject) |
rua | Address that receives daily aggregate reports |
pct | Percentage of messages the policy applies to (default 100) |
sp | Separate policy for subdomains |
adkim / aspf | Alignment mode: r (relaxed, default) or s (strict) |
fo | Failure reporting option; fo=1 requests a report if either SPF or DKIM fails |
For the official tag definitions, see RFC 7489 (DMARC).
Rolling Out DMARC Gradually: none → quarantine → reject
Turning on DMARC straight at p=reject can make mail from a legitimate source you forgot about (billing system, website form, CRM) disappear completely. Here is a safe rollout plan:
- Monitor (p=none) for at least 2-4 weeks: Collect the
ruareports. They arrive as XML; use a DMARC report analyzer to make them readable. List every source that sends email on your behalf. - Fix your sources: For every legitimate source that shows failing SPF or DKIM alignment in the reports, add it to your SPF record or enable DKIM signing with your domain for that service.
- Quarantine (p=quarantine): Start with a low percentage such as
pct=25, and raise it to 100 if you see no problems. - Reject (p=reject): Move to the final stage once the reports show no legitimate failures. At this point, spoofed email impersonating your domain is rejected before it reaches the recipient.
v=DMARC1; p=quarantine; pct=25; rua=mailto:dmarc-rapor@alanadiniz.com
v=DMARC1; p=reject; rua=mailto:dmarc-rapor@alanadiniz.com
If you send bulk email, we cover Gmail and Yahoo's requirement for DMARC at p=none or stricter in our bulk sender requirements guide.
How to Verify Your Records
DNS changes propagate based on the TTL. Once they do, check the records from the command line.
Linux and macOS:
dig +short TXT alanadiniz.com
dig +short TXT dkim._domainkey.alanadiniz.com
dig +short TXT _dmarc.alanadiniz.com
Windows (Command Prompt or PowerShell):
nslookup -type=TXT alanadiniz.com
nslookup -type=TXT dkim._domainkey.alanadiniz.com
nslookup -type=TXT _dmarc.alanadiniz.com
Testing with a real message is the most reliable method:
- Gmail header check: Send an email to your own Gmail address and open "Show original" on the message. You should see
PASSon the SPF, DKIM, and DMARC lines. - mail-tester.com: Send an email to the temporary address it gives you and see your authentication, content, and blocklist score.
- Authentication-Results header: Every receiving server writes its results to this header;
dkim=pass header.d=alanadiniz.comshows that alignment is correct too.
Example: A Complete Record Set
For a typical small business that sends business email through a single provider, with a website contact form that uses the same SMTP server, the DNS zone looks like this:
alanadiniz.com. TXT "v=spf1 mx include:_spf.saglayici.com ~all"
dkim._domainkey.alanadiniz.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
_dmarc.alanadiniz.com. TXT "v=DMARC1; p=none; rua=mailto:dmarc-rapor@alanadiniz.com; fo=1"
When you add a newsletter tool or CRM, add the include value that service gives you to your existing SPF record, and enter the service's own DKIM record (often a CNAME) in DNS. Don't create a new SPF record.
Protect Domains That Don't Send Email, Too
If you own domains that only redirect or aren't used at all, attackers can use them to send spoofed email. Add records that say "no mail is sent from here":
alanadiniz.net. TXT "v=spf1 -all"
_dmarc.alanadiniz.net. TXT "v=DMARC1; p=reject"
If you want a separate policy for subdomains, add the sp= tag to your main DMARC record. For example, while your main domain is still at p=none, sp=reject immediately protects subdomains that don't send email.
Extra Checks If You Run Your Own Mail Server
If you send from your own IP address, the three records alone aren't enough. Your IP's PTR (reverse DNS) record must resolve to your mail server's hostname (e.g., mail.alanadiniz.com), and that hostname must resolve back to the same IP. See our PTR record guide for details. Also make sure your IP is not on any blocklists.
Next Step: Choose the Right Infrastructure
If you'd rather use a ready-made solution than manage records for a handful of business addresses, Sunucu Atlas email hosting plans come with Roundcube webmail, SpamAssassin filtering, and SPF/DKIM support, and you can add your DMARC record in a few minutes using the template in this guide. If you want full control with your own IP address and no account or domain limits, take a look at the mailcow-based mail server option in Istanbul. If you get stuck on a record during setup, you can open a support ticket.
Frequently asked questions
Are SPF, DKIM, and DMARC all required?
They aren't technically required to send email, but major mailbox providers are filtering unauthenticated mail more and more aggressively. Gmail and Yahoo require all three for bulk senders.
Can a domain have two SPF records?
No. More than one v=spf1 record makes the SPF check fail with a permerror. You need to combine all your sources into a single record.
Should I use ~all or -all?
Start with ~all if you aren't sure about all of your sending sources. Because the DMARC policy does the actual enforcement, ~all is enough once DMARC is at reject.
Can I set DMARC to p=reject right away?
It isn't recommended. Collect reports at p=none for a few weeks and verify every legitimate source first, then move gradually to quarantine and reject; otherwise you may block your own legitimate email.
I added the DNS records but the test still fails. Why?
Propagation depends on the TTL, so wait a few hours. Then use dig or nslookup to check for a missing character in the DKIM value, a wrong selector name, or a duplicate SPF record.