Skip to content

hono-email/mailgun provides MailgunAdapter for the Mailgun Messages API. The adapter sends a multipart/form-data request to /v3/{domain}/messages.

import { Body, Html, Text, sendEmail } from 'hono-email'
import { MailgunAdapter } from 'hono-email/mailgun'
const receipt = await sendEmail({
adapter: MailgunAdapter({
apiKey: process.env.MAILGUN_API_KEY!,
domain: process.env.MAILGUN_DOMAIN!,
}),
from: 'sender@example.com',
to: 'recipient@example.com',
subject: 'Welcome',
jsx: (
<Html>
<Body>
<Text>Hello from Mailgun.</Text>
</Body>
</Html>
),
})

For the full list of configuration options, see the Mailgun Options API Reference.

Use apiBaseUrl: 'https://api.eu.mailgun.net' for Mailgun EU domains.

Like all provider adapters, Mailgun supports to, cc, bcc, replyTo, custom headers, and attachments. Inline attachments use cid when the provider supports content IDs.

Type: string

Your Mailgun API key.

Type: string

Your Mailgun sending domain (e.g. 'mg.example.com').

Type: string · Default: 'https://api.mailgun.net'

Override the Mailgun API base URL. Use 'https://api.eu.mailgun.net' for EU domains.

Type: (input: string, init: RequestInit) => Promise<Response>

Custom fetch implementation. Defaults to globalThis.fetch.

Type: string

limits.maxAttachmentSize Optional

Section titled “limits.maxAttachmentSize ”

Type: number

Maximum attachment size in bytes.