Mailtrap Email API notification provider for Medusa
Mailtrap Email API notification provider for Medusa. Requires Medusa 2.22 or a newer 2.x release.
Add the provider to the Notification Module in :
And set the environment variables in :
must be an address on your verified domain. Only one provider can handle a channel, so remove from the channel if it is configured.
| Option | Required | Description |
|---|---|---|
| yes | Mailtrap API token. | |
| yes | Default sender address. overrides it. | |
| no | Default category for emails sent with (not used for template emails). |
With a Mailtrap template: is the template UUID and holds the template variables.
Or inline, with :
A failed send throws and the notification is marked as failed.
MIT
npm install mailtrap-medusa1module.exports = defineConfig({2 modules: [3 {4 resolve: "@medusajs/medusa/notification",5 options: {6 providers: [7 {8 resolve: "mailtrap-medusa/providers/mailtrap",9 id: "mailtrap",10 options: {11 channels: ["email"],12 api_key: process.env.MAILTRAP_API_KEY,13 from: process.env.MAILTRAP_FROM,14 },15 },16 ],17 },18 },19 ],20})1MAILTRAP_API_KEY=2MAILTRAP_FROM=1import { Modules } from "@medusajs/framework/utils"2
3const notificationModuleService = container.resolve(Modules.NOTIFICATION)4
5await notificationModuleService.createNotifications({6 to: "customer@example.com",7 channel: "email",8 template: "<template-uuid>",9 data: { name: "Ada" },10})1await notificationModuleService.createNotifications({2 to: "customer@example.com",3 channel: "email",4 template: "order-placed",5 content: {6 subject: "Your order",7 html: "<p>Thanks for your order.</p>",8 text: "Thanks for your order.",9 },10})