Back
G
Docs
npm install
Documentation

Get Started.

Everything you need to set up Guralnik Mailer from zero to production — step by step.

Quick Start

Get guralnik-mailer running in your project in under 60 seconds.

1
Install the package
npm install guralnik-mailer
2
Run the setup wizard
npx guralnik-mailer
3
Send your first email
Use mailer.send() in your code
Tip
The setup wizard creates your mailer.config.json automatically. You can also create it manually — see the Configuration section below.

Installation

Guralnik Mailer is available on npm. Install it as a dependency in your project:

Using npm

Terminal
1npm install guralnik-mailer

Using yarn

Terminal
1yarn add guralnik-mailer

Using pnpm

Terminal
1pnpm add guralnik-mailer

Interactive Setup Wizard

After installation, run the interactive setup wizard. It walks you through provider selection, theme choice, and language configuration:

Terminal
1npx guralnik-mailer

The wizard will ask you three questions:

  1. Email provider — choose Resend, SendGrid, SMTP, AWS SES, or Mailgun
  2. Design theme — pick from 10 pre-built aesthetics (e.g. midnight, minimal, modern)
  3. Default language — select from 10 supported languages

After answering, the wizard generates your mailer.config.json in the project root. Setup typically takes under 10 seconds.

Configuration

All configuration lives in a single mailer.config.json file at the root of your project. Here is a complete example with all available options:

mailer.config.json
1{
2  "provider": "resend",
3  "apiKey": "re_your_api_key_here",
4  "from": "Your Brand <hello@your-domain.com>",
5  "replyTo": "support@your-domain.com",
6  "theme": {
7    "designType": "midnight",
8    "colors": {
9      "primary": "#059669",
10      "background": "#111827",
11      "text": "#f9fafb",
12      "accent": "#34D399"
13    },
14    "logo": "https://your-domain.com/logo.png",
15    "brandName": "Your Brand"
16  },
17  "locale": "en",
18  "preview": {
19    "port": 3001
20  }
21}

Config Reference

KeyTypeDescription
providerstringEmail provider: "resend" | "sendgrid" | "smtp" | "ses" | "mailgun"
apiKeystringAPI key for your chosen provider
fromstringDefault sender address (e.g. "Brand <hello@domain.com>")
replyTostring?Optional reply-to address
theme.designTypestringTheme preset: midnight, minimal, modern, playful, mono, warm, forest, ocean, rose, slate
theme.colorsobject?Override individual colors (primary, background, text, accent)
theme.logostring?URL to your logo image
theme.brandNamestring?Your brand name displayed in emails
localestringDefault language code: en, de, fr, es, it, nl, pt, pl, sv, he
preview.portnumber?Port for the live preview server (default: 3001)
Warning
Never commit your apiKey to version control. Use environment variables instead — see the Environment Variables section.

Medusa v2 Integration

Guralnik Mailer integrates seamlessly with Medusa v2. The SmartMedusaAdapter automatically listens to 22 Medusa events and dispatches the correct email template — zero subscriber logic required.

Step 1 — Install in your Medusa project

Terminal
1npm install guralnik-mailer

Step 2 — Create the subscriber file

Create a new subscriber file in your Medusa project. The adapter handles everything automatically:

src/subscribers/mailer.ts
1import { SmartMedusaAdapter } from "guralnik-mailer";
2
3const adapter = new SmartMedusaAdapter();
4
5export default async function mailerSubscriber({
6  data,
7  eventName,
8}: any) {
9  await adapter.handleEvent(eventName, data);
10}
11
12export const config = {
13  event: SmartMedusaAdapter.getSupportedEvents(),
14  context: { subscriberId: "guralnik-mailer" },
15};

Step 3 — Run your mailer config wizard

Terminal
1npx guralnik-mailer

That's it. Medusa will now automatically trigger emails for all supported events.

Supported Medusa Events

order.placed
order.canceled
order.completed
order.updated
order.shipment_created
order.fulfillment_created
order.payment_captured
order.payment_failed
order.refund_created
order.return_requested
order.exchange_requested
order.transfer_requested
customer.created
customer.updated
auth.password_reset
auth.verify_account
invite.created
cart.created
gift_card.created
product.back_in_stock
customer.account_deleted
order.delivered

Node.js Standalone

You can use Guralnik Mailer in any Node.js, Express, Fastify, or serverless project — no Medusa required.

Basic Usage

send-email.ts
1import { mailer } from "guralnik-mailer";
2
3await mailer.send(
4  "OrderConfirmation",   // template name
5  "customer@example.com", // recipient
6  {
7    locale: "en",
8    name: "Jane Doe",
9    orderId: "ORD-12345",
10    items: [
11      {
12        title: "Ceramic Espresso Mug",
13        quantity: 2,
14        price: "45.00",
15        currency: "€",
16      },
17    ],
18  }
19);

API Reference

mailer.send() Signature
1mailer.send(
2  templateName: string,   // name of the template (e.g. "Welcome")
3  to: string | string[],  // recipient email(s)
4  data: {
5    locale?: string;      // language code (default: config locale)
6    [key: string]: any;   // template-specific data
7  },
8  options?: {
9    from?: string;        // override sender
10    replyTo?: string;     // override reply-to
11    subject?: string;     // override auto-generated subject
12    cc?: string[];        // CC recipients
13    bcc?: string[];       // BCC recipients
14  }
15): Promise<{ id: string }>
Info
The mailer.send() function returns a promise with the message ID from your email provider. You can use this for logging or tracking.

Sending to Multiple Recipients

bulk-send.ts
1await mailer.send("NewsletterWelcome", [
2  "user1@example.com",
3  "user2@example.com",
4  "user3@example.com",
5], {
6  locale: "de",
7  brandName: "My Store",
8});

Email Providers

Guralnik Mailer supports five email providers out of the box. You choose your provider during setup, or set it in mailer.config.json.

Resendresendrecommended
Modern developer-first email API. Recommended for most projects.
SendGridsendgrid
Enterprise-grade email delivery by Twilio.
AWS SESses
Amazon Simple Email Service. Great for AWS-native stacks.
SMTPsmtp
Any standard SMTP server (Gmail, Outlook, custom).
Mailgunmailgun
Powerful transactional email API.

SMTP Configuration Example

If you choose SMTP, provide the connection details in your environment variables:

mailer.config.json
1{
2  "provider": "smtp",
3  "smtp": {
4    "host": "smtp.gmail.com",
5    "port": 587,
6    "secure": false,
7    "auth": {
8      "user": "your-email@gmail.com",
9      "pass": "your-app-password"
10    }
11  },
12  "from": "Your Brand <your-email@gmail.com>"
13}
Warning
For Gmail, you need to create an App Password in your Google Account security settings. Regular passwords won't work with SMTP.

Themes

Guralnik Mailer ships with 10 professionally designed themes. To switch themes, change one word in your config — all 19 templates instantly adapt.

midnight
Dark, elegant, premium
minimal
Clean black & white
modern
Bright, tech-forward
playful
Bold, vibrant, fun
mono
Subtle, understated
warm
Earthy, inviting tones
forest
Natural, green accents
ocean
Cool blue-cyan palette
rose
Soft pink, luxury feel
slate
Professional, neutral

Switching Themes

Change the designType in your config:

mailer.config.json
1{
2  "theme": {
3    "designType": "ocean"
4  }
5}

Custom Color Overrides

You can customize individual colors within any theme:

mailer.config.json
1{
2  "theme": {
3    "designType": "midnight",
4    "colors": {
5      "primary": "#8B5CF6",
6      "accent": "#C084FC"
7    }
8  }
9}

Internationalization

Every template ships with translations for 10 languages. Guralnik Mailer automatically selects the correct language based on the locale field when sending.

ENEnglish
DEDeutsch
FRFrançais
ESEspañol
ITItaliano
NLNederlands
PTPortuguês
PLPolski
SVSvenska
HEעברית

Per-Email Language Override

Pass locale in the data object to override the default language for a specific email:

send-german.ts
1await mailer.send("OrderConfirmation", "kunde@example.de", {
2  locale: "de",
3  name: "Max Mustermann",
4  orderId: "ORD-99887",
5  items: [{ title: "Keramik Tasse", quantity: 1, price: "22.00", currency: "€" }],
6});
Tip
Hebrew (he) automatically enables right-to-left (RTL) layout in all templates.

Template Reference

Guralnik Mailer includes 19 production-ready templates organized into 4 categories. Each template is fully responsive, theme-aware, and available in all 10 languages.

Customer & Account

Welcomename, brandName
PasswordResetname, resetLink, expiresIn
CustomerVerifyname, verifyLink
InviteCreatedinviterName, teamName, inviteLink
AccountDeletedname

Order Processing

OrderConfirmationname, orderId, items[], total, shippingAddress
ShipmentCreatedname, orderId, trackingNumber, trackingUrl, carrier
OrderDeliveredname, orderId, reviewLink
OrderCanceledname, orderId, reason, refundAmount

Post-Purchase

OrderRefundname, orderId, refundAmount, refundMethod
OrderReturnname, orderId, returnLabel, instructions
OrderExchangename, orderId, originalItem, newItem
OrderTransfername, orderId, newOwnerEmail
OrderPaymentFailedname, orderId, retryLink

Marketing

ReviewRequestname, orderId, productName, reviewLink
AbandonedCartname, items[], cartLink
GiftCardCreatedrecipientName, senderName, amount, code, redeemLink
BackInStockname, productName, productLink
NewsletterWelcomename, brandName

Preview Server

Guralnik Mailer includes a built-in live preview server so you can view every template locally before sending. It supports hot reload, theme switching, and test email sending.

Start the Preview Server

Terminal
1npx guralnik-mailer preview

This starts a local server at http://localhost:3001 (configurable via preview.port in your config).

Features

  • Template browser — browse all 19 templates in a sidebar
  • Live theme switching — toggle between themes in real-time
  • Desktop/Mobile toggle — test responsive layouts
  • Send test emails — dispatch a test email to any address directly from the preview
  • Hot reload — changes to your config are reflected instantly
Tip
The preview server is development-only and not included in production builds. It's safe to always have it configured.

Environment Variables

For production, you should use environment variables instead of hardcoding secrets in your config file. Guralnik Mailer automatically reads from .env.

.env
1# Email provider API key
2MAILER_API_KEY=re_your_api_key_here
3
4# Optional overrides
5MAILER_FROM="Your Brand <hello@your-domain.com>"
6MAILER_REPLY_TO=support@your-domain.com
7
8# SMTP-specific (only if using SMTP provider)
9SMTP_HOST=smtp.gmail.com
10SMTP_PORT=587
11SMTP_USER=your-email@gmail.com
12SMTP_PASS=your-app-password

When environment variables are set, they automatically override the corresponding values in mailer.config.json. Your config file can then omit sensitive values:

mailer.config.json (production-safe)
1{
2  "provider": "resend",
3  "from": "Your Brand <hello@your-domain.com>",
4  "theme": {
5    "designType": "midnight"
6  },
7  "locale": "en"
8}
Warning
Always add .env to your .gitignore. Never commit API keys or credentials to version control.

FAQ

QDo I need Medusa to use Guralnik Mailer?

No. Guralnik Mailer works standalone with any Node.js project. The Medusa adapter is optional — you can use mailer.send() directly in Express, Fastify, Next.js API routes, or any backend.

QCan I customize the HTML templates?

Yes. All templates are React-based (using React Email under the hood). You can extend or override individual templates by placing custom versions in your project.

QIs it free?

Yes. Guralnik Mailer is open-source under the MIT license. It's free to use in personal and commercial projects.

QWhich email providers require paid plans?

That depends on the provider. Resend offers a generous free tier (100 emails/day). SendGrid also has a free tier. AWS SES is pay-per-use at $0.10/1000 emails. SMTP depends on your server.

QCan I add custom translations?

Yes. You can override or extend the built-in translations by providing custom translation files in your project. See the GitHub repository for the translation file format.

QDoes it support attachments?

Yes. You can pass attachments in the options parameter of mailer.send(). Attachments support buffers, streams, and file paths.

QWhat about email deliverability?

Deliverability depends on your email provider and domain configuration (SPF, DKIM, DMARC). Guralnik Mailer generates clean, standards-compliant HTML that renders correctly across all major email clients.

Ready to start?

Install the package and send your first email in under a minute.

View on GitHubnpm install →