EN
  • English
  • Русский
  • ქართულიsoon
  • Українськаsoon
  • Shqipsoon
  • Azərbaycancasoon
  • Türkçesoon
Get in touch
Crypto exchangersHotels & apartmentsEmail & accountsScams & fraud

SPF, DKIM, DMARC Setup for Crypto Exchange and Hotel Domains

SPF, DKIM and DMARC setup: who sends mail from your domain, records for Google Workspace, Microsoft 365, Yandex 360 and Mail.ru, DMARC to reject, testing.

Читать на русском →

On this page

If your crypto exchange, hotel or aparthotel uses email on its own domain (info@obmen-example.com, reservations@hotel-example.com), then without SPF, DKIM and DMARC anyone can send a message with your address in the "From" field — "new payment details", "confirm your booking with your card" — and your client's mail service will accept it. After these steps, mail services reject messages from your domain that you did not send, and you receive reports on every such attempt.

Plan

Step What we do Time
1 List everyone who sends email from your domain 20 min
2 Look at the current DNS records 5 min
3 Publish one correct SPF record 15 min
4 Enable DKIM in your mail service 15 min
5 Publish DMARC in monitoring mode 5 min
6 Review the reports for 2–4 weeks 15 min a week
7 Tighten DMARC to reject and lock down unused domains 15 min
8 Test with a real and a spoofed message 15 min

What real cases have shown

  • Business email compromise (BEC): according to the FBI's 2023 report, about $2.9 billion in losses. The typical trick is a message "from a supplier" or "from the company" with new payment details.
  • Since February 2024, Google and Yahoo require bulk senders to have SPF, DKIM and DMARC; messages without them increasingly land in spam or get rejected — so without these records your genuine emails suffer too.
  • Phishing of hotel guests (Secureworks, 2023 — details in the article "Booking.com extranet"): guests receive messages in the hotel's name asking them to "confirm their card". If the hotel has no DMARC, such a message can even be sent from the hotel's own address.

What follows from this:

  1. Any server can send a message with your address → SPF lists who is allowed (step 3).
  2. The address can be forged even with a correct SPF → DKIM signs messages with the domain's key (step 4).
  3. Without a policy, the recipient's mail service doesn't know what to do with a forgery → DMARC reject (steps 5, 7).
  4. Turning on reject blindly means losing your own emails from the website or PMS → first the sender list and the reports (steps 1, 6).
  5. Domains you don't send from get spoofed too → "empty" protection for unused domains (step 7).

Step 1. List everyone who sends email from your domain

How to do it. Fill in the table — there are usually more senders than you think:

Who sends Example address Through what Needed in SPF/DKIM
Staff mail info@, reservations@ Google Workspace / Microsoft 365 / Yandex 360 / Mail.ru yes
Website: forms, requests noreply@ website server or SMTP plugin yes
PMS, hotel booking system booking@ PMS vendor's server yes (the vendor's include)
Newsletters news@ newsletter service yes
Accounting software, invoices accounting@ on-premises or cloud yes

Ask your PMS, website and newsletter vendors: "What SPF record should we add, and do you support DKIM for our domain?"

Done if: for every sender you know what it sends mail through.

Step 2. Look at the current DNS records

Resolve-DnsName example.ge -Type TXT | Select-Object -ExpandProperty Strings
Resolve-DnsName _dmarc.example.ge -Type TXT | Select-Object -ExpandProperty Strings
Resolve-DnsName example.ge -Type MX

What to look for:

  • strings starting with v=spf1 — there must be exactly one: two SPF records = none;
  • a v=DMARC1 record on _dmarc.example.ge;
  • MX — who hosts your mail.

Records are changed wherever the domain's DNS is managed: at the registrar, in Cloudflare or at your hosting provider. The domain's NS servers show where: Resolve-DnsName example.ge -Type NS (for example, *.ns.cloudflare.com means Cloudflare).

Done if: you know where the records are changed and what they currently contain.

Step 3. Publish one correct SPF record

How to do it. One TXT record at the domain root (example.ge) that includes every sender from step 1:

Mail service What to add to SPF
Google Workspace include:_spf.google.com
Microsoft 365 include:spf.protection.outlook.com
Yandex 360 include:_spf.yandex.net
Mail.ru for Business include:_spf.mail.ru
Your own website server ip4:<server IP>
PMS, newsletters include: from the vendor's instructions

Example for a hotel on Google Workspace with a website on its own server:

v=spf1 include:_spf.google.com ip4:203.0.113.25 ~all
  • ~all — "don't trust anyone else", in soft form; after step 6 — -all.
  • The record may contain no more than 10 mechanisms that require DNS lookups (include, a, mx); otherwise SPF breaks.

Check: Resolve-DnsName example.ge -Type TXT — one v=spf1 string.

Done if: there is one SPF record, and it contains every sender from step 1.

Step 4. Enable DKIM in your mail service

How to do it. The mail service generates the DKIM key; you publish its public part in DNS:

  • Google Workspace: admin.google.com → Menu → Apps → Google Workspace → Gmail → Authenticate email → Generate New Record (key length 2048 if your DNS host supports it, otherwise 1024; the default selector prefix is google) → add the TXT record google._domainkey → Start authentication.
  • Microsoft 365: Microsoft Defender portal (security.microsoft.com) → Email & collaboration → Policies & rules → Threat policies → Email authentication settings → DKIM (direct link — security.microsoft.com/authentication) → your domain → add two CNAME records, selector1._domainkey and selector2._domainkey, with the values the portal shows → Enable.
  • Yandex 360: organization admin console → Domains → next to the domain, Set up DKIM → copy the value from the DKIM signature setup block into the TXT record mail._domainkey → once DNS has updated, on the Domains page click Confirm domain → Check. If the domain is delegated to Yandex DNS, the signature is set up automatically.
  • Mail.ru for Business (VK WorkSpace): in the admin panel, open the domain settings and copy the DKIM record — use exactly the name and value the panel shows.
  • Website, PMS, newsletters — follow the vendor's instructions (each has its own selector).

Check: send a message to Gmail → ⋮ → Show original → DKIM: PASS with your domain.

Done if: messages from every sender in step 1 are DKIM-signed with your domain.

Step 5. Publish DMARC in monitoring mode

How to do it. A separate mailbox for reports (for example, dmarc@example.ge) and a TXT record on _dmarc.example.ge:

v=DMARC1; p=none; rua=mailto:dmarc@example.ge; fo=1
  • p=none — nothing is blocked yet, we only collect reports;
  • rua — where mail services send daily aggregate reports (XML in an archive).

Done if: Resolve-DnsName _dmarc.example.ge -Type TXT shows the record, and the first reports arrive in the mailbox within 1–2 days.

Step 6. Review the reports for 2–4 weeks

How to do it. Save the attachments from the report mailbox to a folder and run the script — it shows which IPs sent mail from your domain and whether they passed the checks:

# dmarc_report.py — summary of DMARC reports from a folder with .xml, .xml.gz, .zip
import sys, gzip, zipfile, collections, xml.etree.ElementTree as ET
from pathlib import Path

def xmls(folder):
    for f in Path(folder).iterdir():
        if f.suffix == ".zip":
            with zipfile.ZipFile(f) as z:
                for n in z.namelist():
                    yield z.read(n)
        elif f.suffix == ".gz":
            yield gzip.open(f).read()
        elif f.suffix == ".xml":
            yield f.read_bytes()

stats = collections.Counter()
for data in xmls(sys.argv[1]):
    root = ET.fromstring(data)
    org = root.findtext("report_metadata/org_name")
    for rec in root.iter("record"):
        ip = rec.findtext("row/source_ip")
        n = int(rec.findtext("row/count") or 0)
        dkim = rec.findtext("row/policy_evaluated/dkim")
        spf = rec.findtext("row/policy_evaluated/spf")
        stats[(ip, dkim, spf, org)] += n

print(f"{'IP':<40} {'DKIM':<6} {'SPF':<6} {'emails':>6}  report from")
for (ip, dkim, spf, org), n in stats.most_common():
    mark = "" if "pass" in (dkim, spf) else "  <-- failed"
    print(f"{ip:<40} {dkim:<6} {spf:<6} {n:>6}  {org}{mark}")
py dmarc_report.py C:\dmarc\reports

How to read the "failed" lines:

Who it is What to do
Your sender from step 1 (website, PMS) add it to SPF (step 3) or enable DKIM (step 4)
An unknown IP with many messages someone is sending in your name — step 7 will stop them
Mail forwarding (mailing lists, redirects) usually fails SPF but passes DKIM — that's normal

Done if: for two weeks in a row all your senders show pass, and "failed" appears only for other people's IPs.

Step 7. Tighten DMARC to reject and lock down unused domains

How to do it.

  1. One week on quarantine, then reject — change the _dmarc record:
v=DMARC1; p=quarantine; rua=mailto:dmarc@example.ge; fo=1
v=DMARC1; p=reject; rua=mailto:dmarc@example.ge; fo=1
  1. In SPF, replace ~all with -all.
  2. Domains you don't send mail from (old ones, "just in case" ones, registered look-alikes such as obmenexample.com for obmen-example.com) — forbid them from sending entirely:
example-old.ge.          TXT   "v=spf1 -all"
_dmarc.example-old.ge.   TXT   "v=DMARC1; p=reject"
example-old.ge.          MX    0 .
  1. Consider which look-alikes of your domain you should register yourself: with and without a hyphen, in the national zone and in .com, with a common typo.

Done if: the main domain has p=reject and -all, and unused domains are blocked from sending.

Step 8. Test with a real and a spoofed message

How to do it.

  1. A real message from each sender (mail, website form, PMS) to a Gmail mailbox → Show original: SPF: PASS, DKIM: PASS, DMARC: PASS.
  2. A spoofed message — only for your own domain: from a server that is not in SPF (for example, a test virtual machine), send a message to your own Gmail mailbox with your address in the "From" field:
swaks --to <your_mailbox>@gmail.com --from info@example.ge --server gmail-smtp-in.l.google.com

Expected result — the Gmail server rejects it with a reference to the DMARC policy, and a day later a "failed" line with the test machine's IP appears in the report (step 6).

Done if: real messages pass, the spoofed one is rejected.

Checklist

# What to check How to verify ☐
1.1 Everyone who sends mail from the domain is known In the step 1 table, "through what" is filled in for every row; the list is cross-checked against the website, PMS, newsletters and accounting ☐
1.2 Vendors have answered about SPF and DKIM You have a written answer from the website, PMS and newsletter vendors: which include: to add and how to enable DKIM for your domain ☐
2.1 You know where DNS is changed Resolve-DnsName example.ge -Type NS shows the DNS provider; login to its panel is confirmed ☐
2.2 The old records are saved The output of the three step 2 commands is saved to a file before any changes — in case you need to roll back ☐
3.1 There is exactly one SPF record Resolve-DnsName example.ge -Type TXT — one string starting with v=spf1 ☐
3.2 SPF contains every sender Every row of the step 1 table has a matching include: or ip4: in the record ☐
3.3 SPF needs no more than 10 DNS lookups Count include, a, mx, including those nested inside other includes (an online SPF check shows the total) — no more than 10 ☐
4.1 DKIM is enabled in the mail service In the service's panel (Google Admin, Microsoft Defender, Yandex 360, VK WorkSpace), the domain's DKIM status shows signing enabled ☐
4.2 The DKIM key is published in DNS Resolve-DnsName google._domainkey.example.ge -Type TXT (use your selector) — a string with v=DKIM1 and p=; for Microsoft 365 — CNAMEs selector1._domainkey and selector2._domainkey ☐
4.3 Each sender's messages are signed A message from mail, the website form, the PMS and the newsletter to Gmail → ⋮ → Show original — each shows DKIM: PASS with your domain ☐
5.1 The DMARC record is published Resolve-DnsName _dmarc.example.ge -Type TXT — v=DMARC1; p=none; rua=mailto:dmarc@… ☐
5.2 Reports are arriving Within 1–2 days the dmarc@ mailbox has messages with .zip or .gz attachments ☐
6.1 The script parses the reports py dmarc_report.py C:\dmarc\reports prints an "IP — DKIM — SPF — emails" table ☐
6.2 Your senders pass two weeks in a row In the summaries for the last two weeks, your services' IPs show pass for DKIM or SPF ☐
6.3 Every "failed" line is explained For every flagged IP it is recorded whether it is yours (fixed in step 3 or 4), forwarding or someone else's ☐
7.1 The main domain is on reject Resolve-DnsName _dmarc.example.ge -Type TXT — p=reject ☐
7.2 SPF ends with -all Resolve-DnsName example.ge -Type TXT — the string v=spf1 … -all ☐
7.3 Unused domains are locked down For each one: TXT v=spf1 -all, p=reject on _dmarc, Resolve-DnsName <domain> -Type MX — a null MX with priority 0 ☐
7.4 Look-alike domains are decided on In the list of variants (with and without a hyphen, .com, a common typo), each is marked "registered by us" or "taken — by whom" ☐
8.1 Real messages pass every check A message from each sender to Gmail → Show original — SPF, DKIM and DMARC: PASS ☐
8.2 The spoofed message is rejected swaks from the test machine to your own Gmail mailbox — the server rejects it with a reference to the DMARC policy ☐
8.3 The spoofing shows up in the report A day later the step 6 summary has a line with the test machine's IP marked "failed" ☐

Questions

How do SPF, DKIM and DMARC differ?

SPF is the list of servers allowed to send mail from the domain. DKIM is a signature on every message made with the domain's key; it can't be forged and usually survives forwarding. DMARC tells the recipient's mail service what to do with a message if neither SPF nor DKIM confirmed the domain in the "From" field, and where to send reports.

Do I really need all three records?

To protect against spoofing — yes: only DMARC with p=reject tells the recipient's mail service to reject someone else's message, and it relies on SPF and DKIM. Besides, Gmail requires SPF or DKIM from all senders, and all three from those who send more than 5,000 messages a day to Gmail.

How do I check SPF, DKIM and DMARC online?

Check the records with the step 2 commands or any online DNS checker, such as our domain security check — it shows the same strings. A more reliable check is the result itself: send a message to Gmail → Show original — it shows whether SPF, DKIM and DMARC passed for that specific message (step 8).

How long until the records start working?

A new record is usually visible within a few minutes, less often within a few hours. A changed one — once the old one's cache lifetime (TTL) expires: you can see it in the Resolve-DnsName output, in seconds.

Can I set p=reject right away without waiting for reports?

For a domain nobody sends mail from — yes, right away (step 7). For a working domain — only if you know every sender for certain: a forgotten website form or PMS will stop delivering mail under reject, and you'll find out from your clients. The step 6 reports are exactly what catches these forgotten senders.

Does DMARC apply to subdomains?

Yes. If a subdomain has no _dmarc record of its own and the main record has no sp= tag, news.example.ge gets the same policy as example.ge. So check messages from subdomains in the reports before moving to reject.

My SPF has more than 10 includes. What do I do?

Remove senders you no longer use, and list your own server with ip4: — this mechanism uses no DNS lookups. Newsletters can be moved to a separate subdomain (for example, news.example.ge) with its own SPF record.

Will DMARC protect us if an employee's mailbox is hacked?

No. A message from a hacked mailbox goes out through your real server and passes SPF, DKIM and DMARC. What protects against this is signing in to mail with a second factor — a passkey or an authenticator app.

How can I tell if someone is already sending emails in our name?

The main source is the step 6 reports: unknown IPs with many messages marked "failed". Other signs: clients forward you emails "from you" that you never sent, and your mailbox receives non-delivery notices for messages you didn't write.

Will this protect against emails from a look-alike domain (obmen-examplle.com)?

No: DMARC protects only your domain. Against look-alikes, what helps is registering the obvious variants (step 7) and a rule for clients: "we change payment details only in person at the office."

Our email is on Gmail.com without our own domain — what should we do?

An @gmail.com address can't be spoofed — Google has its own DMARC. But it's harder for clients to tell your mailbox from a look-alike one; for a business, it's better to have your own domain with the settings from this article.


Note: Mail services' menu items change — check them against their documentation.

Sources

  1. Google — Email sender guidelines (sender requirements since February 2024)
  2. Google Workspace — Set up DKIM
  3. Microsoft — Use DKIM to validate outbound email from your custom domain
  4. RFC 7489 — DMARC
  5. RFC 7208 — SPF (10 DNS lookup limit, section 4.6.4; ip4 needs no lookups)
  6. FBI IC3 — Internet Crime Report 2023 (BEC losses: $2.9 billion)
↑