Sending Email Notifications

Once configured, you can send email notifications using the Notification Module.

Simple Text Email

import { Modules } from "@medusajs/framework/utils"

// Inside an API route, workflow, or subscriber
const notificationService = container.resolve(Modules.NOTIFICATION)

await notificationService.createNotifications({
  to: "[email protected]",
  channel: "email",
  content: {
    subject: "Order Confirmation",
    text: "Thank you for your order! Your order #12345 has been confirmed."
  }
})

HTML Email

await notificationService.createNotifications({
  to: "[email protected]",
  channel: "email",
  content: {
    subject: "Welcome to Our Store",
    html: `
      <h1>Welcome!</h1>
      <p>Thank you for creating an account.</p>
      <a href="https://example.com/shop">Start Shopping</a>
    `
  }
})

Common Use Cases

Custom From Address

You can override the default from address for specific emails:

await notificationService.createNotifications({
  from: "[email protected]", // Override default from
  to: "[email protected]",
  channel: "email",
  content: {
    subject: "Support Response",
    text: "We've received your support request..."
  }
})