These integration guides are not official documentation and the Strapi Support Team will not provide assistance with them.
When building a CMS-powered app with Strapi, you’ll often need to send transactional emails, from password resets to user notifications.
In this guide, you’ll learn how to integrate Postmark to handle email delivery reliably and efficiently.
Why Use Postmark?
Integrate Postmark with Strapi to deliver emails quickly and keep them out of spam folders by focusing on deliverability. To ensure you're following email deliverability best practices, it's crucial to use a reliable email service.
Key features that stand out:
Real-time Monitoring and Reporting: See bounces, opens, and link clicks as they happen, so you can track performance and address issues promptly. This level of visibility helps in understanding sender reputation, which is vital for maintaining high deliverability rates.
Developer-Friendly API: Postmark's straightforward API supports both SMTP and HTTP, fitting seamlessly into various programming environments. If you're exploring options, you might be interested in the best APIs for sending emails and the best email APIs for developers.
For more details on Postmark’s capabilities, check their official documentation.
Why Use Strapi?
Strapi is the leading open-source headless CMS offering features, like customizable APIs, role-based permissions, multilingual support, etc. It simplifies content management and integrates effortlessly with modern frontend frameworks.
Explore the Strapi documentation for more details.
Strapi 5 Highlights
The out-of-the-box Strapi features allow you to get up and running in no time: 1. Single types: Create one-off pages that have a unique content structure. 2. Draft and Publish: Reduce the risk of publishing errors and streamline collaboration. 3. 100% TypeScript Support: Enjoy type safety & easy maintainability 4. Customizable API: With Strapi, you can just hop into your code editor and edit the code to fit your API to your needs. 5. Integrations: Strapi supports integrations with Cloudinary, SendGrid, Algolia, and others. 6. Editor interface: The editor allows you to pull in dynamic blocks of content. 7. Authentication: Secure and authorize access to your API with JWT or providers. 8. RBAC: Help maximize operational efficiency, reduce dev team support work, and safeguard against unauthorized access or configuration modifications. 9. i18n: Manage content in multiple languages. Easily query the different locales through the API. 10. Plugins: Customize and extend Strapi using plugins.
Learn more about Strapi 5 feature.
See Strapi in action with an interactive demo
How to Integrate Postmark with Strapi 5 for Email Delivery
Step 1: Create an account on Postmark
Head over to Postmark and create an account.
You will get a confirmation email to confirm your sender signature. Ensure you click the "Confirm Sender Signature".
Step 2: Get Postmark API token
After successful signup and email confirmation, navigate to the "API Tokens"
Step 3: Create Environment Variables
Inside your Strapi environment variable file .env, create the following environment variables:
1POSTMARK_API_TOKEN=your-postmark-api-token
2POSTMARK_EMAIL_ADDRESS=your-postmark-email-addressStep 4: Install Postmark Email Provider in Strapi
Run any of the command below to install the Postmark email provider plugin in your Strapi project.
1# using yarn
2yarn add @strapi-community/provider-email-postmark
3
4# using npm
5npm i @strapi-community/provider-email-postmarkStep 5: Update Plugin Config file
After successfully installing the Postmark email provider plugin, update your plugin configuration file with the following:
1// Path: ./config/plugin.ts
2
3module.exports = ({ env }) => ({
4 // ...
5 email: {
6 config: {
7 provider: "@strapi-community/provider-email-postmark",
8 providerOptions: {
9 apiKey: env("POSTMARK_API_TOKEN"),
10 },
11 settings: {
12 defaultFrom: env("POSTMARK_EMAIL_ADDRESS"),
13 defaultTo: env("POSTMARK_EMAIL_ADDRESS"),
14 defaultReplyTo: "code@ijs.to",
15 defaultVariables: {
16 sentBy: "strapi",
17 },
18 },
19 },
20 },
21 // ...
22});👋 NOTE If you created a message stream, add
defaultMessageStream: "my-stream"to thesettingsproperty above.
Next, restart your Strapi development server.
Step 6. Test Postmark in your Strapi Application
Testing in the Admin Panel
Navigate to the email plugin configuration page in your Strapi admin to test your Postmark email provider: Settings > EMAIL PLUGIN > Configuration.
You should see the @strapi-community/provider-email-postmark as your email provider, and your Postmark default sender email address as configured in your config file above.
Enter an email address and click the "Send test email". If you get the success toast notification, then you have successfully integrated Postmark in your Strapi application.
Testing in your Strapi Code
For this example, let's use the bootstrap() lifecycle function to send an email.
Locate the ./src/index.ts file and add the following code:
1// Path: ./src/index.ts
2
3import type { Core } from "@strapi/strapi";
4
5export default {
6 /**
7 * An asynchronous register function that runs before
8 * your application is initialized.
9 *
10 * This gives you an opportunity to extend code.
11 */
12 register(/* { strapi }: { strapi: Core.Strapi } */) {},
13
14 /**
15 * An asynchronous bootstrap function that runs before
16 * your application gets started.
17 *
18 * This gives you an opportunity to set up your data model,
19 * run jobs, or perform some special logic.
20 */
21 bootstrap({ strapi }: { strapi: Core.Strapi }) {
22 const sendTestEmail = async () => {
23 await strapi.plugins.email.services.email.send({
24 to: process.env.POSTMARK_EMAIL_ADDRESS,
25 text: "Hello Theodore! Testing Postmark and Strapi integration ",
26 subject: "Testing Postmark",
27 });
28 };
29
30 sendTestEmail();
31 },
32};👋 NOTE The code above runs every time you start Strapi. So, ensure you remove the
sendTestEmailfunction as we only used it for testing.
Restart your Strapi dev server, and check your email inbox.
Congratulations! You have successfully integrated Postmark and Strapi!
GitHub Code
For the full code, visit this repository.
Strapi Open Office Hours
If you have any questions about Strapi 5 or just would like to stop by and say hi, you can join us at Strapi's Discord Open Office Hours, Monday through Friday at 12:30 pm - 1:30 pm CST: Strapi Discord Open Office Hours
For more details, visit the Strapi documentation and Postmark documentation.