Skip to content
Back to Blog
guide
deliverability
dns

Automate SPF, DKIM, and DMARC with HostStack DNS

By Michael Andersen5 min readFact-checked November 9, 2026

Every team that ships transactional email has the same friction at the start. You generate SPF, DKIM, and DMARC records in your email provider's dashboard, paste them into your DNS provider, hit "verify," and wait. Sometimes it works. Sometimes you typo a semicolon in the DKIM key, the DNS provider quotes the TXT differently than the email provider expects, and you spend an afternoon debugging. The cycle repeats for every new sending subdomain you add.

This post is about how to skip that loop when your DNS is on HostStack and your email goes through PostStack: the integration writes every record a sending domain needs into your zone as soon as you add the domain, and keeps them in sync afterwards. It is not a tutorial on what the records mean — for that, read how to set up SPF, DKIM and DMARC. This is what the automation does, exactly, and where it stops.

What gets written to your zone

For a domain example.com, these are the records PostStack writes. The values are the real defaults, not placeholders:

RecordNameValue
SPF (TXT)example.comv=spf1 include:poststack.dev ~all
DKIM (TXT)poststack._domainkey.example.comv=DKIM1; k=rsa; h=sha256; p=… (a 2048-bit key generated for this domain)
DMARC (TXT)_dmarc.example.comv=DMARC1; p=quarantine; sp=quarantine; adkim=r; aspf=r; pct=100; rua=mailto:dmarc@poststack.dev
Return-path (CNAME)bounce.example.combounce.poststack.dev

If you turn on inbound mail for the domain, its MX record is written too. The rua address is where receivers send DMARC aggregate reports; PostStack reads that mailbox and shows the parsed reports per domain, so you never handle the XML. The return-path label defaults to bounce and can be changed when you add the domain.

Connecting HostStack

In the PostStack dashboard, open Settings → Integrations → HostStack and paste a HostStack API key (hs_live_…). It has to be a full-access key, because the integration creates and updates records; PostStack checks that when you connect and refuses a read-only one. The key is stored encrypted.

Connecting also back-fills: every domain the team already has is matched against your HostStack zones and its records are written, so you do not have to re-add anything.

What happens when you add a domain

From then on, adding a domain is the only step:

curl -X POST https://api.poststack.dev/domains \
  -H "Authorization: Bearer $POSTSTACK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "example.com"}'
  1. The API creates the domain with status pending, generates its DKIM key, and returns the record list straight away.
  2. In the background, PostStack finds the HostStack zone that contains the domain and creates or updates each record. Each record is labelled PostStack … — auto-managed in HostStack, so it is obvious later where it came from.
  3. A verification job checks pending domains every minute, asking your domain’s authoritative nameservers directly rather than a cache. Once SPF and DKIM are there, the domain flips to verified and a domain.verified webhook fires.

In practice that means a domain is ready to send within a minute or two of the API call, without anyone opening a DNS panel. If no HostStack zone matches the domain, nothing is written and the domain waits for you to publish the records yourself, as it would without the integration.

What happens to records you already have

  • SPF is merged, not replaced. A domain can only have one SPF record, so if you already have one — v=spf1 include:_spf.example-crm.com -all, say — PostStack adds include:poststack.dev to it and keeps your other mechanisms and your all qualifier.
  • DKIM only overwrites DKIM. An existing TXT record at the selector name is replaced only if it is itself a DKIM key.
  • Nothing outside these names is touched. Your website, MX and verification records stay as they are.

DKIM rotation with a connected zone

This is where the integration pays for itself after day one. A DKIM rotation normally needs two DNS edits a week apart — publish the new key, later remove the old one — and the second is the one people forget. With the zone connected:

  1. You start a rotation (POST /domains/:id/dkim/rotate, or one click in the dashboard). The new selector, for example ps-20261109-a3f1._domainkey, is written to HostStack immediately.
  2. PostStack sees the new key on your nameservers, waits 30 minutes for caches, and switches signing to it. No call from you is needed.
  3. Seven days later the old selector is deleted from your zone.

Each step fires a webhook, and the whole thing finishes without a ticket. The DKIM glossary entry explains why the old key is kept for a week.

What you still have to decide

The integration handles records. It does not make policy decisions for you, because those are domain decisions you should own:

  • DMARC enforcement level. The default is p=quarantine — failing mail is treated as suspicious rather than delivered normally. Moving to p=reject is a deliberate step you take once you've watched aggregate reports for a few weeks and confirmed nothing legitimate is failing. PostStack's deliverability dashboard shows those reports parsed and charted.
  • SPF strictness. The default is ~all (soft-fail) because -all rejects any legitimate mail that leaves through a forwarder or a service you forgot. If your existing record already ends in -all, the merge keeps it.
  • Subdomain strategy. Whether to send from mail.acme.com or directly from acme.com is a reputation question, not a DNS one — see transactional vs marketing email. The integration publishes wherever you ask.

If your DNS isn't on HostStack

PostStack has the same integration for Cloudflare zones, connected with a Cloudflare API token on the same Integrations page. For any other DNS host the manual path works: the domain page lists every record with a copy button, a Verify button runs the check on demand, and the page recognises 22 common DNS providers from your nameservers and links to their dashboard. The domains reference covers every record and what each check accepts.

Disconnecting and rolling back

Disconnecting the integration does not delete your DNS records. They stay in your zone exactly as they were last synced — you keep sending, you just stop getting automatic updates when a DKIM key is rotated.

No lock-in beyond "your records live in your DNS provider, where they belong." That is the whole point.

Frequently asked questions

Which DNS records does PostStack write for a sending domain?

Four: an SPF TXT record (v=spf1 include:poststack.dev ~all, merged into any SPF record you already have), a DKIM TXT record at poststack._domainkey.<domain> with a 2048-bit key, a DMARC TXT record at _dmarc.<domain> with p=quarantine and relaxed alignment, and a CNAME from bounce.<domain> to bounce.poststack.dev for the return-path. An MX record is added too if you enable inbound mail.

Can PostStack publish DNS records if my DNS is not on HostStack?

Yes for Cloudflare: PostStack has the same integration for Cloudflare zones, connected with a scoped Cloudflare API token. For any other DNS host you publish the records yourself from the list on the domain page; PostStack recognises 22 common DNS providers from your nameservers and shows provider-specific tips.

How long does verification take with the integration connected?

Records are written in the background right after the domain is created, and PostStack checks pending domains against their authoritative nameservers every minute. A new domain is usually verified within a minute or two, and a domain.verified webhook fires when it is.

What DMARC policy does the integration publish by default?

p=quarantine, with relaxed alignment. Mail that fails authentication is treated as suspicious rather than delivered normally, so a forgery of your domain lands in spam instead of the inbox — observe-only p=none leaves you spoofable for as long as you stay on it. Moving the last step to p=reject is a deliberate decision you make after watching aggregate DMARC reports and confirming nothing legitimate is failing; PostStack's deliverability dashboard surfaces parsed aggregate reports to support that decision.

What happens if I disconnect the HostStack integration?

Your DNS records stay exactly as they were when last synced. You keep sending — you just stop getting automatic record updates, which matters mainly when a DKIM key is rotated: the new selector then has to be published by hand.

Michael Andersen

Michael Andersen

Founder, PostStack

Building PostStack — a European email API hosted in Helsinki, Finland. Background in self-hosting Postfix, deliverability operations, and high-throughput backend systems.

Continue reading

Ready to get started?

Send your first email in under 5 minutes. Free plan included.