Skip to content
Email5 min read

Set up SPF, DKIM and DMARC for your domain

Short answer

Add three TXT records to your domain's DNS: one SPF record on the domain itself listing the servers allowed to send, a DKIM record on a name like default._domainkey holding the public signing key, and a DMARC record on _dmarc telling receivers what to do when checks fail. Start DMARC at p=none and tighten it once the reports look clean.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Before you start
  2. Steps
  3. Troubleshooting
  4. On ArabyHost

These three records are how Gmail, Outlook and other providers decide that a message really came from your domain. Each answers a different question, and you need all three:

Record Answers Where it lives
SPF Is this server allowed to send for the domain? TXT on example.com
DKIM Was the message signed by the domain and left unchanged? TXT on selector._domainkey.example.com
DMARC What to do when checks fail, and where to send reports TXT on _dmarc.example.com

Before you start

  • Find out where your DNS is managed. Look up the nameservers with the DNS lookup tool. If they point to your host, edit records in cPanel → Domains → Zone Editor; if they point to Cloudflare or your registrar, edit them there.
  • List everything that sends email as your domain: the hosting server (staff mail and website forms), Google Workspace or Microsoft 365 if you use them, your newsletter tool, your invoicing system or store.
  • Pick an address for DMARC reports, such as [email protected] (a mailbox or a forwarder).

Steps

1. Create a single SPF record

On cPanel hosting an SPF record usually looks like this:

v=spf1 +a +mx +ip4:203.0.113.10 ~all
  • +a and +mx: allow the servers in the domain’s A and MX records.
  • ip4:: the IP address of the sending server.
  • include:: adds an outside service, e.g. include:_spf.google.com for Google Workspace or include:spf.protection.outlook.com for Microsoft 365. For anything else, copy the value from that provider’s documentation.
  • ~all: mail from anyone not listed is suspicious (SoftFail). -all is stricter and means reject; switch to it once you’re sure the list is complete.

To add it in cPanel: open Zone Editor, click Manage next to the domain, then + Add Record, choose TXT, name example.com., and paste the full record as the value. Alternatively, Email → Email Deliverability → Manage shows a suggested SPF record ready to copy. To combine several services into one record, use the SPF generator.

Two rules you can’t break: one SPF record per domain, and no more than 10 DNS lookups. Every include, a and mx counts; ip4 doesn’t.

2. Enable DKIM and publish the key

cPanel generates a DKIM key automatically and publishes it under the selector default:

default._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
  • If DNS is hosted with your host, the record is usually already there: confirm it in Email Deliverability.
  • If DNS is elsewhere, copy the value from Email Deliverability → Manage (DKIM section) and add it as a TXT record named default._domainkey. Copy the whole key with no stray spaces or line breaks.
  • Each outside service has its own key and selector, so a domain can have several DKIM records: unlike SPF. In Google Workspace you generate the key under Admin console → Apps → Google Workspace → Gmail → Authenticate email (default selector google); Microsoft 365 uses two CNAME records, selector1._domainkey and selector2._domainkey.

3. Add DMARC in monitoring mode

Start with a policy that blocks nothing and only collects reports:

_dmarc.example.com.  TXT  "v=DMARC1; p=none; rua=mailto:[email protected]; fo=1"
Tag Meaning
p Policy: none monitor, quarantine send to spam, reject refuse
rua Where daily aggregate reports are sent
pct Percentage of mail the policy applies to, useful when ramping up
adkim / aspf Alignment: r relaxed (default) or s strict
sp Policy for subdomains

The DMARC generator builds the record for you. One point many people miss: DMARC passes only if SPF or DKIM passes and is aligned with the domain in the From header. A third-party service that signs with its own domain rather than yours will fail DMARC even when its SPF passes.

4. Test the records

Give DNS a moment, then check from a terminal:

dig +short TXT example.com
dig +short TXT default._domainkey.example.com
dig +short TXT _dmarc.example.com

On Windows use nslookup -type=TXT _dmarc.example.com, or skip the command line and use the TXT lookup tool.

Then the real test: send a message to a Gmail account, open it and choose Show original. You want SPF: PASS, DKIM: PASS and DMARC: PASS.

5. Tighten DMARC gradually

Read the reports arriving at your rua address for two to four weeks. They’re compressed XML files, much easier to read through a DMARC report analysis service. Once every legitimate service passes:

  1. Change to p=quarantine; pct=25, then raise the percentage step by step to 100.
  2. After a quiet, stable period, switch to p=reject.

From then on, anyone spoofing your domain can’t get fake messages delivered to your customers.

Troubleshooting

  • SPF PermError: there are two records starting with v=spf1, or more than 10 lookups. Merge them into one. Details in SPF PermError.
  • dkim=fail or no key for signature: the published key doesn’t match the server’s key, got truncated when copied, or the name was doubled to default._domainkey.example.com.example.com because the DNS panel appends the domain automatically. In that case enter only default._domainkey.
  • DMARC fails although SPF passes: the third-party service’s envelope domain (Return-Path) isn’t yours. Enable DKIM signing with your domain in that service.
  • Changes don’t show up: the old value is cached until its TTL expires, or you edited DNS somewhere your nameservers don’t point to.
  • Cloudflare: TXT records aren’t proxied, but the mail record must be DNS only or mail clients won’t connect.

On ArabyHost

For domains pointed to ns1.arabicode.com and ns2.arabicode.com, SPF and DKIM are created automatically for every domain with email, and you can see both under Email Deliverability in cPanel, one click away in the Araby Panel. What’s left for you is adding a DMARC record in the DNS editor and tightening it once the reports look right. If your DNS is at Cloudflare or your registrar, copy the ready-made values from Email Deliverability and add them there. See our business email plans; Arabic-speaking support can help you review the records.

FAQ

Can a domain have more than one SPF record?

No. A domain must have exactly one TXT record starting with v=spf1, otherwise the result is PermError. If several services send for you, merge them into one record with an include for each.

Should I start DMARC at p=reject?

It's not recommended. Start at p=none to collect reports and find every service sending as you, then move to quarantine and finally reject once all your legitimate mail passes.

How long until new records work?

A brand-new record usually shows up within minutes; changing an existing one can take until the old TTL expires. Check from an external lookup tool before judging the result.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.