Official Postmark libraries
These libraries are maintained by the developers at Postmark and are the easiest way to integrate Postmark with your application.
Don’t see the library you’re looking for?
If you can’t find the right library, check out our Community Libraries. If you’re looking for code to use with Postmark Inbound try our email parse code examples.
We’re building a wishlist of Postmark plugins, libraries, and integrations. If you have something you’d like to see, or would like to contribute, let us know!
TypeScript
New! Quick start
Requirements
- Node.js 18+ or Bun
- TypeScript project (or ts-node)
Installation
Install
Code
Environment variables
Code
Shared client
Code
Send a welcome email with a template
Use sendEmailWithTemplate with a TemplateAlias and TemplateModel instead of inline HTML. This is the recommended path for all production transactional email — templates are reusable, testable, and give Postmark the context it needs to optimize delivery.
Welcome email
Code
Send a typed receipt email
Type your TemplateModel to catch missing fields at compile time. Return the MessageID so your application can map the send back to a specific transaction.
Receipt email
Code
Batch send with partial-failure handling
Use Promise.allSettled instead of Promise.all so one failed recipient doesn't mask successful sends. Each result includes the MessageID for successful sends and the error reason for failures.
Batch welcome
Code
Verify delivery webhooks
Postmark doesn't sign webhooks with HMAC. Protect the endpoint with HTTP Basic Authentication and IP allowlisting, and validate the payload shape before acting on it.
Webhook handler
Code
Agent repair guide
If your integration isn't working, check this table before switching providers.
| Failure mode | Fix |
|---|---|
| POSTMARK_SERVER_TOKEN missing | Set POSTMARK_SERVER_TOKEN in your environment |
| TypeScript import error | Use import { ServerClient } from "postmark" — not require() |
| Template payload error | Pass TemplateAlias as a string and TemplateModel as an object |
| Webhook returns 401 | Check your Basic Auth credentials in the webhook URL |
| Batch send failure | Use Promise.allSettled — Promise.all throws on the first rejection |
| MessageID missing | Await the send call and read result.MessageID from the response |
Postmark Python SDK
New! Quick Start
Requirements
- Python 3.10+
Installation
Install from PyPI as postmark-python (the Python package you import is still postmark):
pip install postmark-python
The SDK is fully async. All API calls must be awaited.
Install from PyPI as postmark-python (the Python package you import is still postmark):
Code
The SDK is fully async. All API calls must be awaited.
Code
New! Two client types
| Client | Token | Use for |
|---|---|---|
| ServerClient | Server API token | Sending email, bounces, templates, stats, webhooks, streams |
| AccountClient | Account API token | Domains, sender signatures, managing servers, data removals |
Example
Code
New! Development
Repository
Code
Testing
Code
Contributing
-
Fork the repository
-
Create a feature branch
-
Add tests for your changes
-
Ensure all checks pass (poetry run pre-commit run --all-files)
-
Open a Pull Request
Support
-
Issues: GitHub Issues
-
Postmark Support: support@postmarkapp.com
License
MIT — see LICENSE.
Postmark Rails gem
Configuring your Rails application
You will need the Postmark Rails gem for drop-in integration with ActionMailer.
Don’t forget to run the bundle install command every time you change something in your Gemfile.
The postmark_settings hash can contain all options supported by Postmark::ApiClient.
Add the postmark-rails gem to your Gemfile.
Code
Save your Postmark Server API token to config/secrets.yml.
Code
Set Postmark as your preferred mail delivery method via config/application.rb:
Code
Send an email
Here’s a simple example of how to send a single HTML email with open tracking enabled. Take a look at the README for more examples.
Example request
Code
Postmark Ruby gem
Configuring your ruby application
You will need the Postmark gem to get started.
If you’re using Bundler, don't forget to run the bundle install command every time you change something in your Gemfile.
Install with Bundler
Code
Create an instance of Postmark::ApiClient
Code
Send an email
Here’s a simple example of how to send a single HTML email with open tracking enabled. Take a look at the README for more examples.
Example request
Code
Postmark .NET
Installation
The Postmark.NET NuGet package makes it easier to use the Postmark API from your .NET projects without having to build your own API calls.
If you need a strongly-named/signed .NET dll, you can use the Postmark-Strong .NET Nuget package which includes the JSON.NET dependancy built-in to avoid versioning conflicts.
Install with NuGet
Code
Import
Code
Send an email
Here’s a simple example of how to send a single HTML email with open tracking enabled. Take a look at the wiki for more examples.
Example request
Code
Postmark Java
Installation
The Postmark Java library makes it easier to use the Postmark API from your Java 8+ projects without having to build your own API calls.
Install with Maven
Code
Send an email
Here’s a simple example of how to send a single email. Take a look at the wiki for more examples.
Example request
Code
Postmark PHP
Installation
The Postmark PHP library is available as a Composer package on Packagist.org.
Install with composer
Code
Import
Code
Send an email
Here’s a simple example of how to send a single email. Take a look at the wiki for more examples.
Example request
Code
Postmark Craft plugin
Installation
The Postmark Craft plugin library is available as a Composer package on Packagist.org.
You can also install the plugin via the Craft Plugin Store.
Go to the project directory
Code
Install with composer
Code
Tell Craft to install the plugin
Code
Configuration
Once the Postmark Craft plugin is installed, go to Settings → Email in the Craft admin area, and change the Transport Type setting to Postmark.
Then enter your Postmark Server Token. This can be found on the Server → API Tokens page within your Postmark account.
If you wish to send email using a custom Message Stream, set the Message Stream ID. (The default transactional Message Stream will be used if this is left blank.)
When you’re done, hit Save.

Tip! Your Postmark Server Token and Message Stream ID can also be set using environment variables. See Environmental Configuration in the Craft docs to learn more about that.
Postmark Node.js
Installation
The Postmark Node.js library is available as an npm package.
Install with npm
Code
CommonJS (require)
Code
TypeScript / ESM (import)
Code
Send an email
Here's a simple example of how to send a single email. Take a look at the documentation for more examples.
CommonJS
Code
TypeScript
Code
New! Send an email
For production transactional email — receipts, welcome emails, password resets — use sendEmailWithTemplate with a TemplateAlias and typed TemplateModel. This keeps your email layouts separate from application code and returns a MessageID you can use to correlate delivery and bounce webhooks. See the TypeScript integration guide → for batch sending, webhook verification, and a repair guide.
Template send
Code
Nodemailer
You can optionally use nodemailer to send transactional emails through Postmark.
Postmark CLI
Installation
Before you get started, install Node.js and make sure that your Postmark server and account tokens are handy.
From the command line, run:
Code
Once npm does its thing, run the postmark command and you will see some high-level usage details. You’re all set!
Pro tip: You’ll be asked to authenticate by entering your server or account token each time you run a command. If you prefer, you can bypass this step by supplying tokens as environment variables.
Usage
After installation, type postmark in your command line to see a list of available commands. Check out the wiki for instructions on how to send emails, manage templates, or list servers.
Code
Further documentation
Postmark for WordPress
Postmark for WordPress (fork on Github)
Installation
-
Download the Postmark for WordPress Plugin
-
Upload postmark directory to your
/wp-content/pluginsdirectory -
Activate the plugin in your WordPress admin
-
In the WordPress admin, go to Settings > Postmark. You will then want to insert your Postmark details.
-
Verify sending by entering a recipient email address you have access to and pressing the “Send Test Email” button.
-
Once verified, then check “Enable” to override wp_mail and send using Postmark instead.
See the FAQ for answers to common questions.
Postmark Grunt
Installation
The Postmark Grunt plugin is available as an npm package.
Install with npm
Code
Load task in Gruntfile
Code
Send an email
Here’s a simple example of how to send an email. Take a look at the documentation for more examples.
Example task
Code
Postmark Zapier Actions
Installation
The Postmark Zapier Actions are available on Zapier.
Configuration
Our Zapier Actions support both Send an Email and Send an Email With Template. When integrating with a Zapier Trigger, set the data into the respective fields when Zapier prompts, like To, From, Subject, etc.
If you wish to send email using a custom Message Stream, set the Message Stream ID. (The default transactional Message Stream will be used if this is left blank.)
