• Интеграции и плагины
  • Сообщество
  • Связаться с нами
Документация

Нужна помощь в разработке плагина интеграции для Medusa?

Написать намНайти плагины

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

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

  • Ресурсы
  • Интеграции и плагины
  • Сообщество
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация
  • Контакты
  • head@gorgojs.com
  • TelegramGitHub
MedusaПлагиныMailgun
Mailgun logo

Mailgun

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

Нужна доработка этого плагина?

Связаться с нами
npm install @webbers/mailgun-notification-medusa
Категория
Уведомления
Создано
Webbers
Версия
1.1.2
Последнее обновление
3 месяца назад
Ежемесячные загрузки
321
Звезды на Github
1
npmNPMGitHubGithub
MedusaПлагиныMailgun

Table of Contents

  • Prerequisites
  • Installation
  • Configuration
    • Configuration Options
    • Environment Variables
  • Usage
  • Local Development and Customization

Prerequisites

  • Node.js v20 or higher
  • Medusa server v2.3.0 or higher
  • A Mailgun account and API key and domain

[!NOTE] If you use Mailgun's EU-hosted infrastructure, you need this url as the api_url: https://api.eu.mailgun.net

Installation

pnpm add @webbers/mailgun-notification-medusa

Configuration

Add the provider to the module in your file:

module.exports = defineConfig({
projectConfig: {
// ...
},
modules: [
// ... other modules
{
resolve: "@medusajs/medusa/notification",
options: {
providers: [
{
resolve:
"@webbers/mailgun-notification-medusa/providers/notification-mailgun",
id: "notification-mailgun",
options: {
channels: ["email"],
apiKey: process.env.MAILGUN_API_KEY,
domain: process.env.MAILGUN_DOMAIN,
from_email: process.env.MAILGUN_FROM,
api_url: process.env.MAILGUN_API_URL, // Only required if using Mailgun's EU-hosted infrastructure
templates: {
"<template-name>": {
subject: "<subject-function>",
template: "<template-function>",
},
},
default_locale: "nl",
},
},
],
},
},
]
})

Configuration Options

OptionDescriptionDefault
Your Mailgun API keyRequired
Your Mailgun domainRequired
Your from email addressRequired
Your email template functionsRequired
The default locale for the emailsRequired
The API url of mailgunOptional

Environment Variables

Create or update your file with the following variables:

MAILGUN_API_KEY="<your-mailgun-api-key>"
MAILGUN_DOMAIN="<your-mailgun-domain>"
MAILGUN_FROM="<your-mailgun-from-email>"
MAILGUN_API_URL="<your-api-url>"

Usage

To set up up your email templates two functions are required per template:

  • A function that takes a locale as a parameter and returns the subject of the email
  • A function that takes the props of the email as a parameter and returns the template of the email For example you could set it up like this:
  1. In the src directory of your medusa server create a directory called
  2. Inside the emails directory create a file called
  3. Inside the order-placed.tsx file add the following code:
import * as React from "react"
import {
Html,
Head,
Preview,
Body,
Container,
Heading,
Text,
} from "@react-email/components"
export const getOrderPlacedTemplate = () => (
<Html>
<Head/>
<Preview>Your order is confirmed</Preview>
<Body>
<Container>
<Heading>Thanks for your order!</Heading>
<Text>Order #12345 has been confirmed.</Text>
<Text>Total: $59.99</Text>
</Container>
</Body>
</Html>
)
export const orderPlacedSubject = (locale: string) => {
switch (locale) {
case "nl":
return "Bestelling bevestigd"
case "en":
return "Order Confirmation"
}
}
  1. In the file add the following code:
module.exports = defineConfig({
projectConfig: {
// ...
},
modules: [
// ... other modules
{
resolve: "@medusajs/medusa/notification",
options: {
providers: [
{
resolve:
"@webbers/mailgun-notification-medusa/providers/notification-mailgun",
id: "notification-mailgun",
options: {
channels: ["email"],
apiKey: process.env.MAILGUN_API_KEY,
domain: process.env.MAILGUN_DOMAIN,
from_email: process.env.MAILGUN_FROM,
api_url: process.env.MAILGUN_API_URL, // Only required if using Mailgun's EU-hosted infrastructure
templates: {
"order-placed": {
subject: orderPlacedSubject,
template: getOrderPlacedTemplate,
},
},
default_locale: "nl",
},
},
],
},
},
]
})

Local development and customization

In case you want to customize and test the plugin locally, refer to the Medusa Plugin docs.

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

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

Nodemailer

От Perseides

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

npm
Уведомления
Postmark logo

Postmark

От Bram-hammer

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

GitHubnpm
Уведомления
Klaviyo logo

Klaviyo

От Ean Carr

Синхронизируйте клиентов, заказы и товары прямо в Klaviyo

GitHubnpm

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

Посмотреть все
Платежи
Pay. logo

Pay.

От Webbers

Принимайте кредитные карты, цифровые платежи и купи сейчас — плати потом

GitHubnpm