Skip to content

Email Types

These types are exported from hono-email/adapter and re-exported from each adapter entry point.


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
}

Visible sender address. See EmailAddress.

Visible recipient address or addresses.

Message subject line.

Rendered HTML body. Set automatically by sendEmail().

Plain-text body. Set automatically by sendEmail().

Carbon-copy addresses.

Blind carbon-copy addresses.

Reply-to address or addresses.

Message attachments. See EmailAttachment.

Custom email headers as a Record<string, string>.

Custom Message-ID header value.

Message date.

SMTP envelope override. See EmailEnvelope.

DKIM signing options. See EmailDkimOptions.


Email message with JSX instead of rendered html/text. Pass to sendEmail().

type EmailMessageDraft = Omit<EmailMessage, 'html' | 'text'> & {
jsx: Child
render?: RenderOptions
}

Email JSX tree. Rendered to html and text by sendEmail().

Render options applied before delivery. See RenderOptions.


Options for sendEmail(): all EmailMessageDraft fields plus an adapter.

type SendEmailOptions = EmailMessageDraft & {
adapter: EmailAdapter
}

Delivery adapter (e.g. ResendAdapter(...), SmtpTransport, CloudflareEmailAdapter(...)).


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)
}

type EmailAddress = string | { address: string; name?: string }

Pass a plain string or an object with address and an optional display name.


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>
}

Attachment filename shown to recipients.

In-memory attachment content. One of content, path, or href is required.

Remote URL or data URI to resolve as attachment content. Local files must be read by user code and passed as content.

Remote URL to fetch as attachment content.

MIME content type.

contentDisposition Optional

Section titled “contentDisposition ”

'attachment' (default) or 'inline'.

Content ID for inline attachments referenced in HTML as cid:....

Encoding for string content: 'base64' | 'hex' | 'utf8'.


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[]
}

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[]
}

Signing domain (e.g. 'example.com').

DKIM selector (e.g. 'mail').

PEM private key string.

Header names to include in the signature.

Header names to exclude from signing.


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.