SendGrid
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.
Example
Section titled “Example”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.
Regional sending
Section titled “Regional sending”Use apiBaseUrl: 'https://api.eu.sendgrid.com' for SendGrid EU regional sending.
Shared adapter features
Section titled “Shared adapter features”Like all provider adapters, SendGrid 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 SendGrid API key.
apiBaseUrl Optional
Section titled “apiBaseUrl ”Type: string · Default: 'https://api.sendgrid.com'
Override the SendGrid API base URL. Use 'https://api.eu.sendgrid.com' for EU regional sending.
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 · Default: 'hono-email'
limits.maxAttachmentSize Optional
Section titled “limits.maxAttachmentSize ”Type: number
Maximum attachment size in bytes.