Claude Templates / S-tier · Foundation

Infrastructure

The Email Infrastructure Playbook

Postmark, the SPF/DKIM/DMARC recipe, drip campaigns, and transactional vs marketing routing.

EMAIL-INFRASTRUCTURE-PLAYBOOK.md · 16 sections · 3,691 words · 30 KB · markdown

By Moe Ameen, founder of BILT · Published · Updated

The Email Infrastructure Playbook sets up an app's sending engine on Postmark: separate transactional and broadcast streams, strict SPF, DKIM and DMARC records, four core tables for templates, campaigns, enrollments and sends, a brand layout wrapper, a drip worker every 15 minutes on Trigger.dev, one-click unsubscribe per RFC 8058, and webhooks for Postmark events and inbound replies.

Key takeaways

  • Two Postmark streams: outbound (transactional) and broadcast (marketing).
  • DNS starts soft (SPF ~all, DMARC p=none) and tightens to -all and quarantine over four weeks.
  • Unsubscribe links are HMAC-signed and support one-click.
  • A Trigger.dev drip worker runs every 15 minutes.

The sending engine. Domain authentication done right the first time, a layout system so every email looks like it came from the same company, drip campaign mechanics, and the routing rule that keeps transactional mail out of the opt-out gate.

What does the Email Infrastructure Playbook build?

It builds sending, tracking and unsubscribes for an app's own email on Postmark, plus the schema that drip campaigns run on.

It also adds an inbound webhook so replies to your emails land in the app.

When should you run it?

Run it in week 2, before the first lifecycle or welcome email. The Email Automation Console and Support Inbox playbooks build on its tables.

Transactional mail goes out on its own stream so receipts and password resets aren't blocked by marketing opt-outs.

What do you need first?

You need a Postmark account with a domain you can verify, DNS access, the Supabase project from Auth & Onboarding, a Trigger.dev project and your app URL for unsubscribe links.

Gmail's sender guidelines require SPF or DKIM from all senders and SPF, DKIM and DMARC above 5,000 messages a day, so set DNS up before anything sends.

What's inside

What does the playbook give you?

When to use it

Week 2, before the first lifecycle email goes out.

Build these first

App Infrastructure

Straight from the file

What does the writing look like?

Reference: src/lib/email/postmark.ts — single-file client with sendPostmarkEmail, sendBroadcastEmail, sendThreadedReply, isRetryablePostmarkError.

Table of contents

Which sections does the file cover?

  1. 0. Use this spec
  2. 1. Architecture
  3. 2. Postmark account setup
  4. 3. DNS auth (SPF + DKIM + DMARC)
  5. 4. Schema
  6. 5. Layout wrapper + marketing-only sentinels
  7. 6. Drip-tick worker
  8. 7. Trigger events + enrollment
  9. 8. Transactional vs marketing routing
  10. 9. Unsubscribe handling (HMAC + one-click)
  11. 10. Postmark events webhook
  12. 11. Inbound mail webhook
  13. 12. Opt-out gating (drip worker side)
  14. 13. Sender resolution + merge context
  15. 14. Common pitfalls
  16. 15. Kickoff prompt

How do you run it?

Drop EMAIL-INFRASTRUCTURE-PLAYBOOK.md into your repo, then tell Claude Code: “Read EMAIL-INFRASTRUCTURE-PLAYBOOK.md and implement it in this codebase.” It's written for an agent to execute end to end. Search the file for angle-bracket placeholders and swap in your own project names, domains, and keys before the first run.

↓ Download the playbook

Who is this for, and who should skip it?

Best for

  • SaaS apps sending their own lifecycle and transactional email
  • Founders who want campaigns stored in their own database
  • Apps that need replies routed back into the product

Not ideal for

  • Cold outreach (see the Cold Email Campaign playbook; Postmark is for opted-in mail)
  • Teams already happy on a hosted email marketing tool
  • Senders on a provider other than Postmark
  • Builders who won't adapt paths: the file points to a reference app you won't have

What else do people ask?

What is in the Email Infrastructure Playbook download?

The Email Infrastructure Playbook is a markdown file of about 3,700 words. It includes example SPF, DKIM, Return-Path and DMARC records, SQL for the four email tables, the layout singleton and the opt-out column, an outline of the drip worker, the unsubscribe token code, webhook handler tables and a kickoff prompt.

Should I set DMARC to p=reject on day one?

No. The Email Infrastructure Playbook runs p=none for weeks 0 to 2, p=quarantine for weeks 2 to 4, and p=reject only after two straight weeks of fully aligned authentication. SPF starts at ~all and moves to -all once DMARC reports show every sender passing.

Does it include the admin screens for managing campaigns?

No. The Email Infrastructure Playbook covers the sending engine and plumbing. The admin console for campaigns, templates, enrollments and analytics lives in the Email Automation Console Playbook, which you run afterward.

How does it stop the same drip email from sending twice?

The Email Infrastructure Playbook writes an email_sends row with a unique dedupe_key (enrollment ID plus step index) before calling Postmark, so a retried worker run hits the unique key and skips the send. The step-advance update also checks the current step, which stops a double fire from skipping ahead.

Do the unsubscribe links expire?

No. The Email Infrastructure Playbook signs unsubscribe tokens with HMAC and never expires them, so opting out works from an old or forwarded email. Its /email/unsubscribe page shows a confirm button on GET and accepts the RFC 8058 one-click POST that Gmail and Apple Mail send.

How do we know this?

This page is based on the playbook file itself, EMAIL-INFRASTRUCTURE-PLAYBOOK.md, which Moe Ameen wrote from the Kompozy codebase (called BKE in the file). We read the file on November 4, 2026; the facts here come from it, not from independent testing in other codebases. Claims about outside rules cite the sources listed below.

Sources

  1. Gmail Help: Email sender guidelines (accessed November 4, 2026)

More infrastructure playbooks

← All 28 Claude templates