Email Types
These types are exported from hono-email/adapter and re-exported from each adapter entry point.
EmailMessage
Section titled “EmailMessage”A fully rendered email message passed to an adapter.
type EmailMessage = { from: EmailAddress to: EmailAddress | EmailAddress[] cc?: EmailAddress | EmailAddress[] bcc?: EmailAddress | EmailAddress[] replyTo?: EmailAddress | EmailAddress[] subject: string html: string text: string attachments?: EmailAttachment[] headers?: Record<string, string> messageId?: string date?: Date envelope?: EmailEnvelope dkim?: EmailDkimOptions}from Required
Section titled “from ”Visible sender address. See EmailAddress.
to Required
Section titled “to ”Visible recipient address or addresses.
subject Required
Section titled “subject ”Message subject line.
html Required
Section titled “html ”Rendered HTML body. Set automatically by sendEmail().
text Required
Section titled “text ”Plain-text body. Set automatically by sendEmail().
cc Optional
Section titled “cc ”Carbon-copy addresses.
bcc Optional
Section titled “bcc ”Blind carbon-copy addresses.
replyTo Optional
Section titled “replyTo ”Reply-to address or addresses.
attachments Optional
Section titled “attachments ”Message attachments. See EmailAttachment.
headers Optional
Section titled “headers ”Custom email headers as a Record<string, string>.
messageId Optional
Section titled “messageId ”Custom Message-ID header value.
date Optional
Section titled “date ”Message date.
envelope Optional
Section titled “envelope ”SMTP envelope override. See EmailEnvelope.
dkim Optional
Section titled “dkim ”DKIM signing options. See EmailDkimOptions.
EmailMessageDraft
Section titled “EmailMessageDraft”Email message with JSX instead of rendered html/text. Pass to sendEmail().
type EmailMessageDraft = Omit<EmailMessage, 'html' | 'text'> & { jsx: Child render?: RenderOptions}jsx Required
Section titled “jsx ”Email JSX tree. Rendered to html and text by sendEmail().
render Optional
Section titled “render ”Render options applied before delivery. See RenderOptions.
SendEmailOptions
Section titled “SendEmailOptions”Options for sendEmail(): all EmailMessageDraft fields plus an adapter.
type SendEmailOptions = EmailMessageDraft & { adapter: EmailAdapter}adapter Required
Section titled “adapter ”Delivery adapter (e.g. ResendAdapter(...), SmtpTransport, CloudflareEmailAdapter(...)).
SendEmailReceipt
Section titled “SendEmailReceipt”Union of SuccessfulSendReceipt | FailedSendReceipt.
type SuccessfulSendReceipt = { successful: true messageId: string accepted: string[] rejected: string[] response: string queued?: boolean queuedRecipients?: string[]}
type FailedSendReceipt = { successful: false accepted: string[] rejected: string[] errorMessages: string[] response?: string cause?: unknown}Narrow on receipt.successful to access success or failure fields:
const receipt = await sendEmail({ ... })if (!receipt.successful) { console.error(receipt.errorMessages)}EmailAddress
Section titled “EmailAddress”type EmailAddress = string | { address: string; name?: string }Pass a plain string or an object with address and an optional display name.
EmailAttachment
Section titled “EmailAttachment”type EmailAttachment = { filename?: string content?: string | Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> path?: string href?: string contentType?: string contentDisposition?: 'attachment' | 'inline' cid?: string encoding?: 'base64' | 'hex' | 'utf8' headers?: Record<string, string>}filename Optional
Section titled “filename ”Attachment filename shown to recipients.
content Optional
Section titled “content ”In-memory attachment content. One of content, path, or href is required.
path Optional
Section titled “path ”Remote URL or data URI to resolve as attachment content. Local files must be read by user code and passed as content.
href Optional
Section titled “href ”Remote URL to fetch as attachment content.
contentType Optional
Section titled “contentType ”MIME content type.
contentDisposition Optional
Section titled “contentDisposition ”'attachment' (default) or 'inline'.
cid Optional
Section titled “cid ”Content ID for inline attachments referenced in HTML as cid:....
encoding Optional
Section titled “encoding ”Encoding for string content: 'base64' | 'hex' | 'utf8'.
EmailEnvelope
Section titled “EmailEnvelope”SMTP envelope override. Useful when the envelope sender differs from the visible From address (e.g. for bounce handling).
type EmailEnvelope = { from?: EmailAddress to?: EmailAddress | EmailAddress[] cc?: EmailAddress | EmailAddress[] bcc?: EmailAddress | EmailAddress[]}EmailDkimOptions
Section titled “EmailDkimOptions”DKIM signing options. Applied by the SMTP adapter and any adapter that supports DKIM.
type EmailDkimOptions = { domainName: string keySelector: string privateKey: string headerFieldNames?: string[] skipFields?: string[]}domainName Required
Section titled “domainName ”Signing domain (e.g. 'example.com').
keySelector Required
Section titled “keySelector ”DKIM selector (e.g. 'mail').
privateKey Required
Section titled “privateKey ”PEM private key string.
headerFieldNames Optional
Section titled “headerFieldNames ”Header names to include in the signature.
skipFields Optional
Section titled “skipFields ”Header names to exclude from signing.
EmailAdapter
Section titled “EmailAdapter”The interface implemented by all delivery adapters.
type EmailAdapter = { send(message: EmailMessage): Promise<SendEmailReceipt>}Pass a custom implementation when no built-in adapter fits your provider.