Email SDK
Adapters

Postmark

Configure the fetch-based Postmark adapter.

The Postmark adapter calls the Postmark Email API directly. It does not add a runtime dependency.

Postmark logo
Postmark
@opencoredev/email-sdk/postmark
OfficialNot API testedRequest tested
Open website

Before live sends

Create a Postmark server token for the server and message stream you want to send through. Make sure the sender signature or domain is approved in Postmark before using a production from address.

Configure

import { createEmailClient } from "@opencoredev/email-sdk";
import { postmark } from "@opencoredev/email-sdk/postmark";

const email = createEmailClient({
  adapters: [
    postmark({
      serverToken: process.env.POSTMARK_SERVER_TOKEN!,
      messageStream: "outbound",
    }),
  ],
});

Send

const result = await email.send({
  from: "Acme <hello@acme.com>",
  to: [{ email: "user@example.com", name: "Ada" }],
  cc: "billing@example.com",
  replyTo: "support@example.com",
  subject: "Receipt",
  html: "<p>Thanks for your order.</p>",
  headers: {
    "X-Order-ID": "ord_123",
  },
  metadata: {
    orderId: "ord_123",
  },
  tags: [{ name: "type", value: "receipt" }],
  attachments: [
    {
      filename: "receipt.txt",
      content: "Order ord_123",
      contentType: "text/plain",
    },
  ],
});

console.log(result.provider, result.messageId);

Postmark supports one Email SDK tag. The adapter serializes the first tag as name:value and rejects additional tags before the API call.

Options

OptionTypeRequiredNotes
serverTokenstringYesPostmark server token.
baseUrlstringNoDefaults to https://api.postmarkapp.com.
messageStreamstringNoPostmark message stream.
fetchtypeof fetchNoUseful for tests or custom runtimes.
headersRecord<string, string>NoExtra request headers.

Response

The adapter maps Postmark MessageID to id and messageId, and maps returned To to accepted.

CLI smoke test

POSTMARK_SERVER_TOKEN="..." npx email-sdk send \
  --adapter postmark \
  --from "Acme <hello@acme.com>" \
  --to user@example.com \
  --subject "Postmark test" \
  --text "It works"

On this page