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
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | Your Mailgun API key. |
domain | string | Yes | The sending domain configured in Mailgun. |
region | 'us' | 'eu' | No | Use eu for domains in Mailgun's EU region. Defaults to us. |
fetch | typeof fetch | No | A custom fetch implementation. |
Notes
tagsare sent as Mailgun custom variables (v:fields).idempotencyKeyisn't supported. Passing one throws anEmailErrorwith the codeunsupported.sendBatchsends 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
contentIdis uploaded under that ID as its filename. - The returned
idis Mailgun's message ID without the surrounding<and>, as it appears in webhook events.