• Модуль интеграций
  • Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаСтартерыЗапускайте проекты быстрее с готовыми решениями
ЭкспертыПодберите специалиста для разработки и развития вашего проекта на MedusaКейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Представляем готовый к продакшену Medusa DTC Starter от Gorgo

26 августа 2026 г. · Продукт

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Модуль интеграций
  • Стартеры
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
Unsend logo

Unsend

Создавайте шаблоны писем с Unsend

npm install @rokmohar/medusa-plugin-unsend
Категория
Уведомления
Создано
Rokmohar
Версия
1.1.2
Последнее обновление
1 месяц назад
Ежемесячные загрузки
Загрузка данных
Звезды на Github
5
npmNPMGitHubGithub

Unsend plugin for MedusaJS v2

Installation

Run the following command to install the plugin with npm:

Or with yarn:

⚠️ MedusaJS v2.19.0 or newer

This plugin is only for MedusaJS v2.19.0 or newer.

If you are using MedusaJS v2.4.0 - v2.18.x, please use the v1.0.8 version of this plugin.

If you are using MedusaJS v2.3.1 or older, please use the older version of this plugin.

Configuration

Add the plugin to your file:

Instead of the path, you can also use the exported constant, which resolves to the same provider:

ENV variables

Add the environment variables to your and file:

If you want to use with the from this README, use the following values:

Email Templates

The plugin automatically loads email templates from the directory in your project root (or a custom directory specified in the configuration). Each template consists of two files:

  1. A TSX file containing the React component
  2. An optional JSON file for template metadata

Templates are rendered to HTML by the plugin, with the and of your application, before they are sent. The React version bundled with the Unsend SDK is never used.

Template Structure

The email subject is determined in the following order of precedence:

  1. provided in the call
  2. field in the template's metadata JSON file
  3. static property in the TSX file
  4. Kebab-case template name (derived from the filename)

For example, if you have a template named , the subject will fall back to if no other subject is specified.

The template name will be derived from the filename (without the .tsx extension). For example, will be available as the template named .

Template Metadata

The JSON file is optional and can contain the following fields:

  • : Template version (defaults to "1.0.0")
  • : Template subject
  • : Template description
  • : Array of tags for categorizing templates
  • : Template category

Email Subject Precedence

The email subject is determined in the following order of precedence:

  1. provided in the call
  2. field in the template's metadata JSON file
  3. static property in the TSX file
  4. Kebab-case template name (derived from the filename)

For example, if you have a template named , the subject will fall back to if no other subject is specified.

Attachments

Attachments are passed as a top-level field of the call. Each attachment requires a and a base64-encoded :

Passing the attachments in is still supported for backwards compatibility. Unsend only accepts and , so any other field of the Medusa attachment (, , ) is ignored.

Features

  • Attachments: Send file attachments with your emails
  • Environment-specific Configuration: Override settings for different environments (development, staging, production)
  • Rate Limiting: Prevent overwhelming the email service with configurable limits
  • Retry Mechanism: Automatic retries for failed email sends with exponential backoff
  • Template Versioning: Track template versions and changes
  • Template Metadata: Add descriptions, tags, and categories to templates
  • Custom Template Directory: Configure the location of your email templates

Subscribers

You must add the following subscribers to the :

product-upsert.ts

docker-compose

You can add the following configuration for Unsend to your :

Еще в этой категории

Посмотреть все
Уведомления
Nodemailer logo

Nodemailer

От Perseides

Отправляйте email-уведомления через Nodemailer (SMTP)

Загрузка данных
npm
Уведомления
Mailgun logo

Mailgun

От Webbers

Отправляйте и управляйте уведомлениями по электронной почте

Загрузка данных
GitHubnpm
Уведомления
Postmark logo

Postmark

От Bram-hammer

Транзакционные письма через Postmark

Загрузка данных
GitHubnpm

Еще от этого автора

Посмотреть все
Поиск
MeiliSearch logo

MeiliSearch

От Rokmohar

Open-source поисковый движок для вашей витрины

Загрузка данных
GitHubnpm
Платежи
Manual Payment logo

Manual Payment

От Rokmohar

Провайдер по умолчанию для ручного приёма оплаты

Загрузка данных
GitHubnpm
npm install --save @rokmohar/medusa-plugin-unsend
yarn add @rokmohar/medusa-plugin-unsend
1import { loadEnv, defineConfig } from '@medusajs/framework/utils'
2
3loadEnv(process.env.NODE_ENV || 'development', process.cwd())
4
5module.exports = defineConfig({
6 // ... other config
7 plugins: [
8 // ... other plugins
9 {
10 resolve: '@rokmohar/medusa-plugin-unsend',
11 options: {
12 // Required options
13 url: process.env.UNSEND_URL ?? '',
14 api_key: process.env.UNSEND_API_KEY ?? '',
15 from: process.env.UNSEND_FROM ?? '',
16
17 // Optional configuration
18 templateDir: 'custom/templates/path', // Custom template directory
19 retry: {
20 maxAttempts: 5, // Number of retry attempts for failed sends
21 delay: 2000, // Delay between retries in milliseconds
22 },
23 rateLimit: {
24 maxPerMinute: 30, // Maximum emails per minute
25 },
26 // Environment configurations based on NODE_ENV
27 environment: {
28 development: {
29 // Development-specific overrides
30 from: 'dev@example.com',
31 rateLimit: {
32 maxPerMinute: 25,
33 },
34 },
35 staging: {
36 // Staging-specific overrides
37 from: 'stage@example.com',
38 rateLimit: {
39 maxPerMinute: 50,
40 },
41 },
42 production: {
43 // Production-specific overrides
44 from: 'prod@example.com',
45 rateLimit: {
46 maxPerMinute: 100,
47 },
48 },
49 },
50 },
51 },
52 ],
53 modules: [
54 // ... other modules
55 {
56 resolve: '@medusajs/medusa/notification',
57 dependencies: ['unsend'],
58 options: {
59 providers: [
60 // ... other providers
61 {
62 resolve: '@rokmohar/medusa-plugin-unsend/providers/notification',
63 id: 'unsend',
64 options: {
65 channels: ['email'],
66 },
67 },
68 ],
69 },
70 },
71 ],
72})
1import { UNSEND_PROVIDER_PATH } from '@rokmohar/medusa-plugin-unsend'
2
3// ...
4{
5 resolve: UNSEND_PROVIDER_PATH,
6 id: 'unsend',
7 options: {
8 channels: ['email'],
9 },
10}
1# ... others vars
2UNSEND_URL=
3UNSEND_API_KEY=
4UNSEND_FROM=
1# ... others vars
2UNSEND_URL=http://localhost:3000
3UNSEND_API_KEY=test_123456789
4UNSEND_FROM=no-reply@example.org
1// src/templates/emails/ProductUpsert.tsx
2import React from 'react'
3
4const ProductUpsertEmail = (props: any) => {
5 return (
6 <div>
7 <h1>Product Updated</h1>
8 <p>Product ID: {props.productId}</p>
9 </div>
10 )
11}
12
13// Set email subject
14ProductUpsertEmail.Subject = 'Products upserted'
15
16export default ProductUpsertEmail
1// src/templates/emails/ProductUpsert.json
2{
3 "version": "1.0.0",
4 "subject": "Product upsert",
5 "description": "Email template for product updates",
6 "tags": ["product", "update"],
7 "category": "product-notifications"
8}
1await notificationModuleService.createNotifications({
2 to: 'first.last@example.org',
3 channel: 'email',
4 template: 'product-upsert',
5 attachments: [
6 {
7 filename: 'invoice.pdf',
8 content: base64EncodedContent,
9 },
10 ],
11})
1import { SubscriberArgs, SubscriberConfig } from '@medusajs/framework'
2import { IProductModuleService } from '@medusajs/framework/types'
3import { Modules } from '@medusajs/framework/utils'
4import { ProductEvents } from '@medusajs/framework/utils'
5import { UnsendService } from '@rokmohar/medusa-plugin-unsend'
6
7export default async function productCreatedHandler({ event: { data }, container }: SubscriberArgs<{ id: string }>) {
8 const productId = data.id
9
10 // Make sure template is registered, before creating email notifications
11 const unsendService: UnsendService = container.resolve('unsend')
12
13 const notificationModuleService = container.resolve(Modules.NOTIFICATION)
14 await notificationModuleService.createNotifications({
15 to: 'first.last@example.org',
16 channel: 'email',
17 // Use name of the registered template
18 template: 'product-upsert',
19 // Set email subject
20 content: {
21 subject: 'Product upserted',
22 },
23 })
24}
25
26export const config: SubscriberConfig = {
27 event: [ProductEvents.PRODUCT_CREATED, ProductEvents.PRODUCT_UPDATED],
28}
1services:
2 # ... other services
3
4 unsend:
5 image: 'unsend/unsend:latest'
6 ports:
7 - '3000:3000'