These integration guides are not official documentation and the Strapi Support Team will not provide assistance with them.
What Is Mailjet?
Mailjet is a comprehensive email service provider that delivers both transactional and marketing email capabilities through a robust, API-driven platform. If you're looking to integrate Mailjet with Strapi, this email solution provides the reliability and scalability needed for headless CMS architectures.
Mailjet handles two primary email services: transactional emails for automated communications like user registration confirmations, password resets, and order notifications, and marketing emails for campaigns, newsletters, and promotional content. The platform's RESTful API and SMTP compatibility ensure seamless integration with various development stacks, particularly Node.js and JavaScript-based applications.
Developers choose Mailjet for its focus on deliverability, comprehensive analytics, and developer-friendly features. You get detailed insights into email performance, including open rates, click-through rates, and delivery statistics, helping you optimize your communication strategy. The platform excels at managing emails across multiple domains within a single account, perfect for agencies or businesses managing multiple brands.
Why Integrate Mailjet with Strapi
Combining Strapi with Mailjet creates a powerful foundation for modern web applications that need reliable email functionality. When you integrate Mailjet with Strapi, you can manage all email requirements within your headless CMS architecture, whether you're building user-facing applications, internal tools, or complex multi-tenant systems.
The most compelling use cases include automated user registration confirmations, password reset workflows, real-time notifications, and sophisticated marketing campaigns. Strapi's email plugin system connects seamlessly with Mailjet's delivery infrastructure, letting you trigger emails programmatically from your content management workflows or API endpoints.
For JavaScript and Node.js developers, this integration offers significant advantages. You can use Strapi's flexible content types to manage email templates, recipient lists, and campaign data while utilizing Mailjet's proven deliverability rates and analytics. The integration supports both Strapi v4 and v5, ensuring compatibility as you scale your projects.
Technical founders and DevOps engineers benefit from this headless approach because it separates email logic from frontend presentation. You can manage email templates through Strapi's admin interface while your development team focuses on building user experiences. The API-driven architecture means you can easily provide email functionality across multiple applications or services without duplicating configuration.
Community-maintained providers offer additional flexibility, including multi-provider support and enhanced template management. This modular approach ensures your email infrastructure remains adaptable as your technical requirements evolve.
Ready to implement this integration? Explore the Strapi deployment guides to get started with integrating Mailjet with Strapi today, or join the discussions in the Strapi Community Forum for additional support.
Keep in touch with the latest Strapi and Mailjet updates
How to Integrate Mailjet with Strapi
Setting up Mailjet as your email provider in Strapi enables reliable transactional email delivery for user notifications, password resets, and automated campaigns. This integration combines Strapi's flexible content management with Mailjet's robust email infrastructure, giving you complete control over your application's email communications.
Prerequisites
Before integrating Mailjet with your Strapi project, you'll need to ensure your development environment meets specific requirements and have the necessary accounts configured.
Your Strapi project should run on Strapi v4 or v5, with v5 being recommended for its enhanced security features and improved plugin support. If you're upgrading from earlier versions, such as those with Strapi v3.5 features, be sure to review the migration guides. You'll also need Node.js v16.x or higher to ensure compatibility with both Strapi and the Mailjet integration packages.
Create a Mailjet account if you don't already have one, then navigate to your account settings to access the API Key management section, where you can find your Public API Key and Private Secret Key. These credentials authenticate your Strapi application with Mailjet's services, so keep them secure and never commit them directly to your code repository.
Ensure your Strapi project has the email plugin active and accessible. Check that your config
directory exists at the project root and that you can access the Strapi admin panel. Your project structure should include proper environment variable support through a .env
file for storing sensitive configuration data.
Installation
The installation process involves adding the necessary email provider package to your Strapi project. You have two main options for connecting Strapi with Mailjet's API. Install the community-maintained Mailjet provider package using your preferred package manager:
1npm install @strapi/provider-email-mailjet --save
Or, if you are using Yarn:
1yarn add @strapi/provider-email-mailjet
This provider package implements the interface expected by Strapi's email plugin and handles the communication between your application and Mailjet's API. For more advanced functionality, you can install the Symbol IT Mailjet plugin, which provides additional configuration options through the Strapi admin interface:
1npm install -s @symbol-it/strapi-plugin-mailjet
This plugin offers admin-configurable settings, allowing non-technical team members to manage email configurations without developer intervention.
Configuration
Proper configuration ensures secure credential management and reliable email delivery. You'll need to set up environment variables and configure Strapi's plugin settings. Add your Mailjet credentials to your .env
file:
1MAILJET_API_KEY=your_public_api_key_here
2MAILJET_SECRET_KEY=your_private_secret_key_here
These environment variables keep your sensitive API credentials separate from your codebase, following security best practices for production applications. Create or update your config/plugins.js
file with the Mailjet provider configuration:
1module.exports = ({ env }) => ({
2 email: {
3 config: {
4 provider: 'mailjet',
5 providerOptions: {
6 publicApiKey: env('MAILJET_API_KEY'),
7 secretApiKey: env('MAILJET_SECRET_KEY'),
8 },
9 settings: {
10 defaultFrom: 'noreply@yourdomain.com',
11 defaultReplyTo: 'support@yourdomain.com',
12 },
13 },
14 },
15});
This configuration tells Strapi to use Mailjet as the email provider and specifies default sender addresses for your application's emails. The env()
function safely retrieves your API credentials from environment variables. Verify your setup by sending a test email through Strapi's email service:
1await strapi.plugins.email.services.email.send({
2 to: "test@example.com",
3 subject: "Test Email from Strapi",
4 text: "This is a test email to verify the Mailjet integration",
5 html: "<p>This is a test email to verify the Mailjet integration</p>",
6});
This test ensures your integration communicates properly with the API and can deliver emails successfully.
Setting up for Multiple Domains
When managing multiple domains or brands within a single Strapi application, you'll need to configure domain-specific email settings to maintain proper sender reputation and brand consistency.
Configure different sender addresses for multiple domains by extending your plugin configuration:
1module.exports = ({ env }) => ({
2 email: {
3 config: {
4 provider: 'mailjet',
5 providerOptions: {
6 publicApiKey: env('MAILJET_API_KEY'),
7 secretApiKey: env('MAILJET_SECRET_KEY'),
8 },
9 settings: {
10 defaultFrom: env('DEFAULT_FROM_EMAIL', 'noreply@maindomain.com'),
11 defaultReplyTo: env('DEFAULT_REPLY_TO', 'support@maindomain.com'),
12 domains: {
13 'brand1.com': {
14 from: 'noreply@brand1.com',
15 replyTo: 'support@brand1.com'
16 },
17 'brand2.com': {
18 from: 'noreply@brand2.com',
19 replyTo: 'support@brand2.com'
20 }
21 }
22 },
23 },
24 },
25});
Implement domain-specific email sending in your application logic:
1const sendDomainSpecificEmail = async (domain, emailData) => {
2 const domainConfig = strapi.config.get('plugins.email.settings.domains')[domain];
3
4 await strapi.plugins.email.services.email.send({
5 ...emailData,
6 from: domainConfig?.from || strapi.config.get('plugins.email.settings.defaultFrom'),
7 replyTo: domainConfig?.replyTo || strapi.config.get('plugins.email.settings.defaultReplyTo'),
8 });
9};
For each domain you plan to send emails from, configure proper DNS records in Mailjet's dashboard. Set up SPF and DKIM records for each domain to ensure high deliverability rates and prevent your emails from being marked as spam. This step is crucial for maintaining the sender’s reputation across multiple domains.
Keep in touch with the latest Strapi and Mailjet updates
Project Example: Build a Content Hub with Mailjet and Strapi
The "Strapi Content Hub" demonstrates Mailjet integration with practical code examples.
Configuration Setup
1// config/plugins.js
2module.exports = ({ env }) => ({
3 email: {
4 provider: 'mailjet',
5 providerOptions: {
6 apiKey: env('MAILJET_API_KEY'),
7 apiSecret: env('MAILJET_API_SECRET'),
8 version: 'v3.1',
9 },
10 settings: {
11 defaultFrom: env('MAILJET_FROM_EMAIL'),
12 defaultReplyTo: env('MAILJET_REPLY_TO'),
13 },
14 },
15});
Email Service Implementation
1// services/email.js
2module.exports = {
3 async sendWelcomeEmail(user) {
4 try {
5 await strapi.plugins['email'].services.email.send({
6 to: user.email,
7 template_id: 1234567,
8 variables: {
9 firstName: user.username,
10 confirmationUrl: `${process.env.FRONTEND_URL}/confirm?token=${user.confirmationToken}`,
11 },
12 });
13 strapi.log.debug(`Welcome email sent to ${user.email}`);
14 } catch (error) {
15 strapi.log.error(`Error sending welcome email: ${error.message}`);
16 }
17 },
18
19 async sendContentUpdateNotification(subscribers, article) {
20 const messages = subscribers.map(subscriber => ({
21 To: [{ Email: subscriber.email, Name: subscriber.username }],
22 TemplateID: 7654321,
23 TemplateLanguage: true,
24 Variables: {
25 article_title: article.title,
26 article_url: `${process.env.FRONTEND_URL}/articles/${article.slug}`,
27 }
28 }));
29
30 return strapi.plugins['email'].provider.send({ Messages: messages });
31 }
32};
Lifecycle Hooks
1// api/article/models/article.js
2module.exports = {
3 lifecycles: {
4 async afterPublish(result) {
5 const subscribers = await strapi.services.subscriber.find({ active: true });
6 await strapi.services.email.sendContentUpdateNotification(subscribers, result);
7 },
8 },
9};
The project includes authentication flows with welcome and password reset emails, content notifications when articles are published, and newsletter management with unsubscribe handling. It features comprehensive testing, multi-domain configuration, and follows separation of concerns by keeping email logic isolated from business logic.
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, from 12:30 pm to 1:30 pm CST: Strapi Discord Open Office Hours.
For more details, visit the Strapi documentation and the Mailjet documentation.