JSPM

  • Created
  • Published
  • Downloads 229
  • Score
    100M100P100Q94031F
  • License MIT

Mailgun transport for Upyo email library

Package Exports

  • @upyo/mailgun
  • @upyo/mailgun/package.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@upyo/mailgun) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@upyo/mailgun

JSR npm

Mailgun transport for the Upyo email library.

Installation

npm  add       @upyo/core @upyo/mailgun
pnpm add       @upyo/core @upyo/mailgun
yarn add       @upyo/core @upyo/mailgun
deno add --jsr @upyo/core @upyo/mailgun
bun  add       @upyo/core @upyo/mailgun

Usage

import { createMessage } from "@upyo/core";
import { MailgunTransport } from "@upyo/mailgun";
import fs from "node:fs/promises";
import process from "node:process";

const message = createMessage({
  from: "sender@example.com",
  to: "recipient@example.net",
  subject: "Hello from Upyo!",
  content: { text: "This is a test email." },
  attachments: [
    new File(
      [await fs.readFile("image.jpg"), "image.jpg", { type: "image/jpeg" }]
    )
  ],
});

const transport = new MailgunTransport({
  apiKey: process.env.MAILGUN_KEY!,
  domain: process.env.MAILGUN_DOMAIN!,
  region: process.env.MAILGUN_REGION as "us" | "eu",
});

const receipt = await transport.send(message);
if (receipt.successful) {
  console.log("Message sent with ID:", receipt.messageId);
} else {
  console.error("Send failed:", receipt.errorMessages.join(", "));
}

Configuration

See the Mailgun docs for more information about configuration options.

Available Options

  • apiKey: Your Mailgun API key
  • domain: Your Mailgun domain
  • region: Mailgun region (us or eu, defaults to us)
  • timeout: Request timeout in milliseconds (default: 30000)
  • retries: Number of retry attempts (default: 3)
  • tracking: Enable tracking (default: true)
  • clickTracking: Enable click tracking (default: true)
  • openTracking: Enable open tracking (default: true)