These integration guides are not official documentation and the Strapi Support Team will not provide assistance with them.
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 in 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
Setup Strapi 5 Headless CMS
We are going to start by setting up our Strapi 5 project with the following command:
🖐️ Note: make sure that you have created a new directory for your project.
You can find the full documentation for Strapi 5 here.
Install Strapi
npx create-strapi@latest server
You will be asked to choose if you would like to use Strapi Cloud we will choose to skip for now.
Strapi v5.6.0 🚀 Let's create your new project
We can't find any auth credentials in your Strapi config.
Create a free account on Strapi Cloud and benefit from:
- ✦ Blazing-fast ✦ deployment for your projects
- ✦ Exclusive ✦ access to resources to make your project successful
- An ✦ Awesome ✦ community and full enjoyment of Strapi's ecosystem
Start your 14-day free trial now!
? Please log in or sign up.
Login/Sign up
❯ Skip
After that, you will be asked how you would like to set up your project. We will choose the following options:
? Do you want to use the default database (sqlite) ? Yes
? Start with an example structure & data? Yes <-- make sure you say yes
? Start with Typescript? Yes
? Install dependencies with npm? Yes
? Initialize a git repository? Yes
Once everything is set up and all the dependencies are installed, you can start your Strapi server with the following command:
cd server
npm run develop
You will be greeted with the Admin Create Account screen.
Go ahead and create your first Strapi user. All of this is local so you can use whatever you want.
Once you have created your user, you will be redirected to the Strapi Dashboard screen.
Publish Article Entries
Since we created our app with the example data, you should be able to navigate to your Article collection and see the data that was created for us.
Now, let's make sure that all of the data is published. If not, you can select all items via the checkbox and then click the Publish button.
Enable API Access
Once all your articles are published, we will expose our Strapi API for the Articles Collection. This can be done in Settings -> Users & Permissions plugin -> Roles -> Public -> Article.
You should have find
and findOne
selected. If not, go ahead and select them.
Test API
Now, if we make a GET
request to http://localhost:1337/api/articles
, we should see the following data for our articles.
🖐️ Note: The article covers (images) are not returned. This is because the REST API by default does not populate any relations, media fields, components, or dynamic zones.. Learn more about REST API: Population & Field Selection.
So, let's get the article covers by using the populate=*
parameter: http://localhost:1337/api/articles?populate=*
Getting Started with Postmark
Integrating Postmark with Strapi combines Strapi’s intuitive content management with Postmark’s reliable email delivery. If you're considering a switch from other CMS platforms, you might find it helpful to migrate from Contentful to Strapi. A detailed step-by-step guide is available on Strapi's official blog, covering the entire migration process. Here's how to set it up.
Configuring Strapi Environment
Ensure your Node.js and npm versions are current. Keep sensitive data like API keys secure by storing them as environment variables in a .env
file. Consider enhancing security by keeping software and plugins up to date, using HTTPS and SSL certificates, employing strong passwords, taking regular backups, securing web hosts, modifying default settings, and installing security plugins. Ensure that any security plugins used are updated regularly to maintain protection against security risks.
If you're working with other frameworks, you might also want to learn how to validate and send email in PHP.
Installing and Adjusting Settings
Install the Postmark package:
npm install postmark
Then, to configure Postmark in Strapi, obtain your API key from your Postmark account under Server API Tokens. In your Strapi project’s ./config/plugins.js
, include the following setup:
1module.exports = ({ env }) => ({
2 email: {
3 config: {
4 provider: 'postmark',
5 providerOptions: {
6 apiKey: env('POSTMARK_API_KEY'),
7 },
8 settings: {
9 defaultFrom: 'hello@example.com',
10 defaultReplyTo: 'support@example.com',
11 },
12 },
13 },
14});
Code Implementation
To manage email logic in Strapi using Postmark, follow these steps:
- Create a Custom API: Set up a custom API in your Strapi project, which includes generating directories and files for your service, controller, and routes.
- Implement the Email Service: Use Strapi's email service in your controllers to send emails. Example:
1await strapi.plugins['email'].services.email.send(
2 'recipient@example.com',
3 'Welcome!',
4 'Thank you for joining our community.'
5);
- Test the Integration: Create an endpoint in your controller to test email functionality, and configure the route in your routes file.
Ensure you configure Postmark as the email provider according to Postmark's API documentation and Strapi's setup for custom providers. Set the provider to 'postmark' and configure API keys and settings in config/plugins.js
or via environment variables.
That's it - well done!
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.