Send transactional email with Postmark's server client
Use a Postmark server token and explicit message stream for a controlled SDK send, then correlate delivery evidence.
Reviewed
Install the official client with npm install postmark. Supply the approved server token, sender, and controlled recipient as POSTMARK_SERVER_TOKEN, APP_FROM, and TEST_TO through secure runtime configuration.
Submit one transactional message
import postmark from "postmark";
for (const key of ["POSTMARK_SERVER_TOKEN", "APP_FROM", "TEST_TO"]) {
if (!process.env[key]) throw new Error(`Missing ${key}`);
}
const client = new postmark.ServerClient(process.env.POSTMARK_SERVER_TOKEN);
const result = await client.sendEmail({
From: process.env.APP_FROM,
To: process.env.TEST_TO,
Subject: "Postmark controlled test",
TextBody: "A test in the approved transactional stream.",
MessageStream: "outbound",
});
console.log({ messageId: result.MessageID });
outbound is the common default transactional stream; replace it only with a real stream ID configured for your server. Running this module sends real mail.
Preserve the result and failure context
Persist a send intent before submission and retain Postmark’s MessageID. Use server activity and delivery/bounce events to verify the result; acceptance is not inbox placement.
On sender, token, or stream errors, fix the relevant configuration instead of changing recipients to bypass restrictions. For an uncertain timeout, reconcile existing activity before retrying. Never log the server token or entire receipt/password-reset content.
References: official libraries and sending with the API. Existing longer application examples remain in the main guide.