Mailgun
hono-email/mailgun provides MailgunAdapter for the Mailgun Messages API. The adapter sends a multipart/form-data request to /v3/{domain}/messages.
Example
Section titled “Example”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.
Regional sending
Section titled “Regional sending”Use apiBaseUrl: 'https://api.eu.mailgun.net' for Mailgun EU domains.
Shared adapter features
Section titled “Shared adapter features”Like all provider adapters, Mailgun supports to, cc, bcc, replyTo, custom headers, and attachments. Inline attachments use cid when the provider supports content IDs.
Options
Section titled “Options”apiKey Required
Section titled “apiKey ”Type: string
Your Mailgun API key.
domain Required
Section titled “domain ”Type: string
Your Mailgun sending domain (e.g. 'mg.example.com').
apiBaseUrl Optional
Section titled “apiBaseUrl ”Type: string · Default: 'https://api.mailgun.net'
Override the Mailgun API base URL. Use 'https://api.eu.mailgun.net' for EU domains.
fetch Optional
Section titled “fetch ”Type: (input: string, init: RequestInit) => Promise<Response>
Custom fetch implementation. Defaults to globalThis.fetch.
userAgent Optional
Section titled “userAgent ”Type: string
limits.maxAttachmentSize Optional
Section titled “limits.maxAttachmentSize ”Type: number
Maximum attachment size in bytes.