{"_id":"emdash-plugin-postmark","_rev":"2-1392b85d2f4494cfa98b82a0e3c2bbe9","name":"emdash-plugin-postmark","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"emdash-plugin-postmark","version":"0.1.0","keywords":["emdash","emdash-plugin","cms","postmark","email","transactional","smtp","mailer"],"author":{"name":"Nicholas Penree","email":"nick@penree.com"},"license":"MIT","_id":"emdash-plugin-postmark@0.1.0","maintainers":[{"name":"drudge","email":"nick@penree.com"}],"homepage":"https://github.com/drudge/emdash-plugin-postmark#readme","bugs":{"url":"https://github.com/drudge/emdash-plugin-postmark/issues"},"dist":{"shasum":"827a4b311271dae2d7acfd49ef0599cc462eae59","tarball":"https://registry.npmjs.org/emdash-plugin-postmark/-/emdash-plugin-postmark-0.1.0.tgz","fileCount":15,"integrity":"sha512-E6UQ5lusb3xomLqvKaYfS3PaNR+1Rk4XychPNIBIdmu8BeYa92AhZhseVGW2Yr33SHqjbKQ2al3aBF7CuFUrng==","signatures":[{"sig":"MEUCIQCNyDkFqum45OP1fsoApCN1ajHx2DT24Fb/pxK0zTj/1wIgf4o6zzh0muANsE2mR88z0oq2YtEP0k4FrmFLp7+7MHE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":213720},"main":"dist/index.js","type":"module","_from":"file:emdash-plugin-postmark-0.1.0.tgz","types":"./dist/index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./sandbox":"./dist/sandbox-entry.js"},"scripts":{"dev":"tsdown src/index.ts src/sandbox-entry.ts --format esm --dts --watch","test":"vitest run","build":"tsdown src/index.ts src/sandbox-entry.ts --format esm --dts --clean","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"drudge","email":"nick@penree.com"},"_resolved":"/private/var/folders/wp/lnd9f8yd2dg8qmrcrl_dmvmc0000gn/T/d7def7bd9576dc33a40a7c007b2d350d/emdash-plugin-postmark-0.1.0.tgz","_integrity":"sha512-E6UQ5lusb3xomLqvKaYfS3PaNR+1Rk4XychPNIBIdmu8BeYa92AhZhseVGW2Yr33SHqjbKQ2al3aBF7CuFUrng==","repository":{"url":"git+https://github.com/drudge/emdash-plugin-postmark.git","type":"git"},"_npmVersion":"10.9.2","description":"Send EmDash CMS emails through Postmark — settings, delivery log, webhook tracking, live stream/sender pickers.","directories":{},"_nodeVersion":"23.10.0","dependencies":{"ulidx":"^2.4.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"emdash":">=0.9.0","tsdown":"^0.9.5","vitest":"^2.1.8","typescript":"^5.7.3","@types/node":"^22.10.0","@vitest/coverage-v8":"^2.1.8"},"peerDependencies":{"emdash":">=0.9.0"},"_npmOperationalInternal":{"tmp":"tmp/emdash-plugin-postmark_0.1.0_1777672663681_0.4262006536783287","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"emdash-plugin-postmark","version":"0.2.0","description":"Send EmDash CMS emails through Postmark — settings, delivery log, webhook tracking, live stream/sender pickers.","type":"module","main":"dist/index.js","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"},"./sandbox":"./dist/sandbox-entry.js"},"keywords":["emdash","emdash-plugin","cms","postmark","email","transactional","smtp","mailer"],"author":{"name":"Nicholas Penree","email":"nick@penree.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/drudge/emdash-plugin-postmark.git"},"homepage":"https://github.com/drudge/emdash-plugin-postmark#readme","bugs":{"url":"https://github.com/drudge/emdash-plugin-postmark/issues"},"engines":{"node":">=20"},"publishConfig":{"access":"public"},"peerDependencies":{"emdash":">=0.9.0"},"dependencies":{"ulidx":"^2.4.1"},"devDependencies":{"@types/node":"^22.10.0","@vitest/coverage-v8":"^2.1.8","emdash":">=0.9.0","tsdown":"^0.9.5","typescript":"^5.7.3","vitest":"^2.1.8"},"scripts":{"build":"tsdown src/index.ts src/sandbox-entry.ts --format esm --dts --clean","dev":"tsdown src/index.ts src/sandbox-entry.ts --format esm --dts --watch","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","prepublishOnly":"pnpm run build"},"gitHead":"db8073a3bb928beb4bfe4b760999052a5b456f88","types":"./dist/index.d.ts","_id":"emdash-plugin-postmark@0.2.0","_nodeVersion":"20.20.2","_npmVersion":"11.13.0","dist":{"integrity":"sha512-0HYezaZEK7PnvWfK2oJHVG5Lq7jEwWA0yjbdImwh+i5xKTpl21e/n0xys1GAbM5K+AUByqVfnm5eUWavU96AyQ==","shasum":"96fc01cc68fddce33c42d7ab67d7891fc6f59e41","tarball":"https://registry.npmjs.org/emdash-plugin-postmark/-/emdash-plugin-postmark-0.2.0.tgz","fileCount":15,"unpackedSize":214056,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/emdash-plugin-postmark@0.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBskY9umKhxh1jxXxMwxqTMSW5+ET8EsXssu2GF8DPLDAiAWbH8p0nL4J8o4yvEw458/R/gi0Ry0Xg656OcDGwEHCw=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9662ab36-e511-49ce-a9eb-c801081e7ae3"}},"directories":{},"maintainers":[{"name":"drudge","email":"nick@penree.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/emdash-plugin-postmark_0.2.0_1777674006460_0.9922157754506877"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-01T21:57:43.562Z","modified":"2026-05-01T22:20:06.886Z","0.1.0":"2026-05-01T21:57:43.836Z","0.2.0":"2026-05-01T22:20:06.620Z"},"bugs":{"url":"https://github.com/drudge/emdash-plugin-postmark/issues"},"author":{"name":"Nicholas Penree","email":"nick@penree.com"},"license":"MIT","homepage":"https://github.com/drudge/emdash-plugin-postmark#readme","keywords":["emdash","emdash-plugin","cms","postmark","email","transactional","smtp","mailer"],"repository":{"type":"git","url":"git+https://github.com/drudge/emdash-plugin-postmark.git"},"description":"Send EmDash CMS emails through Postmark — settings, delivery log, webhook tracking, live stream/sender pickers.","maintainers":[{"name":"drudge","email":"nick@penree.com"}],"readme":"# emdash-plugin-postmark\n\nSend EmDash CMS emails through [Postmark](https://postmarkapp.com) — settings parity with the official WordPress plugin, plus a delivery log, real-time webhook tracking (deliveries, bounces, opens, clicks), and live stream + sender pickers.\n\n[![CI](https://github.com/drudge/emdash-plugin-postmark/actions/workflows/ci.yml/badge.svg)](https://github.com/drudge/emdash-plugin-postmark/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/emdash-plugin-postmark.svg)](https://www.npmjs.com/package/emdash-plugin-postmark)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n> **`Postmark Settings`** appears in the EmDash admin sidebar after install.\n\n## Features\n\n| | |\n|---|---|\n| ✓ | Drop-in replacement for EmDash's email transport — registers as the exclusive `email:deliver` provider |\n| ✓ | Full settings parity with the official WordPress Postmark plugin (token, sender, stream, force-from, force-HTML, track opens / links, tags, metadata) |\n| ✓ | Environment-variable overrides compatible with WordPress (`POSTMARK_API_KEY`, `POSTMARK_SENDER_ADDRESS`, `POSTMARK_STREAM_NAME`) |\n| ✓ | **Live picker** — Default Stream dropdown populated from `/message-streams` |\n| ✓ | **Live picker** — Default Sender dropdown populated from `/senders` (with optional Account API Token) |\n| ✓ | **Webhook receiver** — secured with a per-installation secret, transitions deliveries through `delivered → bounced → spam_complaint`, counts opens & clicks |\n| ✓ | **Test connection** button validates the token without sending email |\n| ✓ | **Send test email** button sends to the signed-in admin |\n| ✓ | Delivery log with status badges + relative timestamps; queryable by `messageId` (used by the webhook receiver) |\n| ✓ | Source-aware Postmark **Tag** + **Metadata** — filter EmDash sends by source in the Postmark dashboard |\n| ✓ | Retry on 5xx, 429, and network errors with exponential backoff |\n| ✓ | Sandbox-compatible — no Node built-ins; `network:request` capability restricted to `api.postmarkapp.com` |\n\n## Install\n\n```bash\npnpm add emdash-plugin-postmark\n# or\nnpm install emdash-plugin-postmark\n```\n\nRegister in your EmDash site's `astro.config.mjs`:\n\n```ts\nimport { defineConfig } from \"astro/config\";\nimport emdash from \"emdash/astro\";\nimport { postmarkPlugin } from \"emdash-plugin-postmark\";\n\nexport default defineConfig({\n  integrations: [\n    emdash({\n      plugins: [postmarkPlugin()],\n    }),\n  ],\n});\n```\n\nFor a sandboxed install (Cloudflare Workers), use `sandboxed: [postmarkPlugin()]` instead. The plugin is identical in both modes.\n\n## Configure\n\nOpen the EmDash admin → **Postmark Settings** in the sidebar.\n\n| Setting | KV key | Env var override | Notes |\n|---|---|---|---|\n| Server API Token | `settings:serverToken` | `POSTMARK_API_KEY` | Required. From Postmark → your server → API Tokens. |\n| Account API Token | `settings:accountToken` | `POSTMARK_ACCOUNT_TOKEN` | Optional. Enables the live sender-signature picker. From Postmark → Account → API Tokens. |\n| Default Sender | `settings:defaultSender` | `POSTMARK_SENDER_ADDRESS` | Required. Must be a verified sender signature. |\n| Force Default Sender | `settings:forceSender` | — | Always use the Default Sender regardless of caller-supplied `from`. |\n| Message Stream | `settings:defaultStream` | `POSTMARK_STREAM_NAME` | Defaults to `outbound`. Live-picker dropdown. |\n| Track Opens | `settings:trackOpens` | — | Maps to Postmark `TrackOpens`. |\n| Track Links | `settings:trackLinks` | — | `None` / `HtmlOnly` / `HtmlAndText` / `TextOnly`. |\n| Force HTML | `settings:forceHtml` | — | Wrap text-only messages in minimal HTML so links render in all clients. |\n| Default Tag | `settings:defaultTag` | — | Postmark Tag added to every send when \"Auto-tag with source\" is off. |\n| Auto-tag with Source | `settings:autoTagSource` | — | Postmark Tag = source identifier (`system`, `plugin:newsletter`, …). |\n| Include Source as Metadata | `settings:metadataSource` | — | Adds `Metadata.source = \"<source>\"` to every send. |\n| Retry on Transient Errors | `settings:retryEnabled` | — | 3 attempts with exponential backoff. Default on. |\n\nResolution order: **KV → environment variable → built-in default**. The admin UI labels each field with its source.\n\n### Activate as the email provider\n\nAfter saving the token, click **Make active provider**. EmDash will start routing all transactional email — magic-links, invites, password resets, plugin emails — through Postmark.\n\n## Webhooks\n\nThe settings page displays a webhook URL like:\n\n```\nhttps://your-site.example.com/_emdash/api/plugins/postmark/webhook?key=<secret>\n```\n\nPaste it into Postmark → **Servers → your server → Streams → your stream → Webhooks**. Enable the `Delivery`, `Bounce`, `Spam Complaint`, `Open`, and `Click` events you care about.\n\nWhat you get:\n- Delivery rows transition `sent → delivered` once Postmark accepts the message at the recipient MX.\n- Bounces and spam complaints update the row status with the bounce type and description.\n- Opens and clicks are aggregated on the row (`opens`, `clicks`, `firstOpenAt`, `lastClickedUrl`).\n\nThe **Regenerate webhook secret** button rotates the secret. The old URL stops working immediately — update Postmark's webhook config when you rotate.\n\n> **Security note:** Postmark webhooks are not signed (the documented options are URL-embedded Basic Auth or a shared secret in the URL). The plugin uses a 192-bit URL-safe random secret stored in `state:webhookSecret`. Bad keys get a `401` with no body. Treat the URL as a credential.\n\n## Usage from other plugins\n\nOther plugins can send email via the standard EmDash email pipeline once Postmark is the active provider:\n\n```ts\nimport { definePlugin } from \"emdash\";\n\nexport default definePlugin({\n  capabilities: [\"email:send\"],\n  hooks: {\n    \"content:afterPublish\": async (event, ctx) => {\n      await ctx.email!.send({\n        to: \"team@example.com\",\n        subject: `Just published: ${event.content.title}`,\n        text: `${event.content.title} is live.`,\n      });\n    },\n  },\n});\n```\n\nIf `autoTagSource` is on, the email lands in Postmark with `Tag = \"plugin:<your-id>\"` so you can slice metrics by sender.\n\n## Tags & metadata in Postmark\n\nWhen **Auto-tag with source** is on, every email is tagged with its EmDash source:\n\n| Source | Postmark Tag |\n|---|---|\n| EmDash core (magic links, invites, password resets) | `system` |\n| Plugin emails | `plugin:<plugin-id>` |\n| The \"Send test email\" button | `plugin:test` |\n\nThis lets you filter the Postmark **Activity** screen, **Deliverability** stats, and **Outbound** webhooks by source. Combine with **Include Source as Metadata** for richer Postmark searches.\n\n## Troubleshooting\n\n| Postmark Error | Plugin behavior | Fix |\n|---|---|---|\n| `10` (Invalid token) | Non-transient, logged + thrown | Re-check the **Server API Token**. Make sure it's the *server* token, not the account token. |\n| `300` (Invalid sender) | Non-transient, logged + thrown | Add and verify the sender in Postmark → **Sender Signatures**, then update **Default Sender**. |\n| `406` (Inactive recipient) | Non-transient | Recipient is suppressed. Reactivate in Postmark → **Suppressions**. |\n| `100` (Maintenance) | Transient — retried | Postmark window — usually resolves automatically. |\n| HTTP 429 | Transient — retried | Rate-limited; the retry helper backs off. Increase your Postmark plan if persistent. |\n| HTTP 5xx | Transient — retried | Postmark service issue. The retry helper handles short outages. |\n\nThe **Recent deliveries** table on the settings page shows the last 25 attempts with status badges, source, stream, opens, and timestamps.\n\n## FAQ\n\n### Is the plugin sandbox-safe?\n\nYes. The plugin is shipped in EmDash's standard format (no Node built-ins). It declares only `hooks.email-transport:register` and `network:request` capabilities, with `allowedHosts: [\"api.postmarkapp.com\"]`. Sandboxed installs see a capability consent dialog listing exactly that.\n\n### Why two different tokens?\n\nPostmark has two token types:\n- **Server tokens** — scoped to a single Postmark \"server\" (which is really an outbound mail stream). Used for sending email and managing message streams.\n- **Account tokens** — scoped to your whole Postmark account. Used to enumerate sender signatures (`/senders`).\n\nThe plugin needs a server token to send. The account token is optional — supply it only if you want the **Default Sender** dropdown populated automatically.\n\n### Will it work with multiple senders?\n\nThe plugin currently exposes one Default Sender. Per-source routing rules and multi-server support are on the roadmap.\n\n### Can I migrate from another email provider plugin?\n\nYes — EmDash's `email:deliver` hook is exclusive, so installing Postmark and clicking **Make active provider** swaps providers atomically. The previous provider's plugin can stay installed (it just stops receiving traffic).\n\n### What if Postmark is down?\n\nThe retry helper handles transient outages. For longer outages, you'll see `failed` rows in the delivery log. Email pipeline errors propagate to callers (e.g., the user-invite endpoint will fail), so the operator sees the issue.\n\n## Development\n\n```bash\ngit clone https://github.com/drudge/emdash-plugin-postmark\ncd emdash-plugin-postmark\npnpm install\npnpm test               # run vitest\npnpm test:coverage      # with coverage report\npnpm typecheck          # tsc --noEmit\npnpm build              # produce dist/ via tsdown\n```\n\nThe plugin runs against `emdash >= 0.7.0`. Tests use vitest with mocked storage / KV / fetch — no live Postmark account required for CI.\n\nTo run the plugin against a local EmDash dev site, point a workspace path dependency at this repo's root and add `postmarkPlugin()` to your `astro.config.mjs`.\n\n## License\n\n[MIT](LICENSE) © Nicholas Penree\n","readmeFilename":"README.md"}