Skip to content

hono-email/sendgrid provides SendGridAdapter for the Twilio SendGrid Mail Send API. The adapter sends JSON directly to /v3/mail/send and maps SendGrid error responses to SendEmailReceipt.

import { Body, Html, Text, sendEmail } from 'hono-email'
import { SendGridAdapter } from 'hono-email/sendgrid'
const receipt = await sendEmail({
adapter: SendGridAdapter({
apiKey: process.env.SENDGRID_API_KEY!,
}),
from: { address: 'sender@example.com', name: 'Sender' },
to: ['recipient@example.com'],
subject: 'Welcome',
jsx: (
<Html>
<Body>
<Text>Hello from SendGrid.</Text>
</Body>
</Html>
),
})

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

Use apiBaseUrl: 'https://api.eu.sendgrid.com' for SendGrid EU regional sending.

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

Type: string

Your SendGrid API key.

Type: string · Default: 'https://api.sendgrid.com'

Override the SendGrid API base URL. Use 'https://api.eu.sendgrid.com' for EU regional sending.

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

Custom fetch implementation. Defaults to globalThis.fetch.

Type: string · Default: 'hono-email'

limits.maxAttachmentSize Optional

Section titled “limits.maxAttachmentSize ”

Type: number

Maximum attachment size in bytes.