Providers

Mailgun

Send email through Mailgun.
import { createClient } from '@nicogenz/emails-sdk';
import { mailgun } from '@nicogenz/emails-sdk/mailgun';

const email = createClient({
  provider: mailgun({
    apiKey: process.env.MAILGUN_API_KEY!,
    domain: 'mg.acme.com',
  }),
});

Options

OptionTypeRequiredDescription
apiKeystringYesYour Mailgun API key.
domainstringYesThe sending domain configured in Mailgun.
region'us' | 'eu'NoUse eu for domains in Mailgun's EU region. Defaults to us.
fetchtypeof fetchNoA custom fetch implementation.

Notes

  • tags are sent as Mailgun custom variables (v: fields).
  • idempotencyKey isn't supported. Passing one throws an EmailError with the code unsupported.
  • sendBatch sends the emails one by one, because Mailgun has no endpoint for sending different emails in one request.
  • Mailgun identifies inline images by their filename, so an attachment with a contentId is uploaded under that ID as its filename.
  • The returned id is Mailgun's message ID without the surrounding < and >, as it appears in webhook events.
Copyright © 2026