Skip to content

Adapter Options

Each delivery adapter has specific configuration options passed when initializing the transport or adapter function.


SMTP settings used with SmtpTransport.

type SmtpTransportOptions = {
connector: SmtpConnector
hostname: string
port: number
secure?: boolean | 'starttls'
auth?: SmtpAuth
dkim?: EmailDkimOptions
clientName?: string
connectionTimeout?: number
greetingTimeout?: number
socketTimeout?: number
limits?: EmailAttachmentLimits
pool?: {
maxConnections?: number
maxMessages?: number
}
}

Type: SmtpConnector

Runtime-specific socket connector. Built-in connectors are available for different runtimes (e.g. nodeSmtpConnector for Node.js, cloudflareSmtpConnector for Cloudflare Workers).

Type: string

SMTP server host name (e.g., 'smtp.gmail.com').

Type: number

SMTP server port (e.g., 587 or 465).

Type: boolean | 'starttls'

TLS mode. true uses implicit TLS (usually on port 465), 'starttls' upgrades the connection using STARTTLS after the initial handshake (usually on port 587).

Type: SmtpAuth

Authentication configuration. See SmtpAuth.

Type: EmailDkimOptions

Default DKIM signing options for all outgoing messages on this transport. See EmailDkimOptions.

Type: string · Default: 'localhost'

Name sent during the SMTP EHLO/HELO handshake.

connectionTimeout Optional

Section titled “connectionTimeout ”

Type: number

Connection timeout in milliseconds.

Type: number

Greeting timeout in milliseconds.

Type: number

Socket idle timeout in milliseconds.

Type: EmailAttachmentLimits

Attachment size limits.

  • maxConnections: Maximum number of concurrent connections in the pool (Default: 1).
  • maxMessages: Maximum number of messages to send over a single connection before retiring it.

type SmtpAuth =
| {
type?: 'plain'
username: string
password: string
}
| {
type: 'login'
username: string
password: string
}
  • type: Mechanism used for SMTP authentication ('plain' or 'login').
  • username: Username credential.
  • password: Password credential.

When using SmtpTransport, the runtime-specific socket creation is handled by a connector.

type SmtpConnector = {
connect(
address: SmtpSocketAddress,
options: SmtpConnectorOptions,
): SmtpSocket | Promise<SmtpSocket>
}
  • SmtpSocketAddress: An object containing { hostname: string, port: number }.
  • SmtpConnectorOptions: Contains { secureTransport: 'off' | 'on' | 'starttls' }.

An abstraction layer for the underlying TCP connection:

type SmtpSocket = {
readable: ReadableStream<Uint8Array>
writable: WritableStream<Uint8Array>
opened?: Promise<unknown>
closed?: Promise<void>
startTls?: () => SmtpSocket | Promise<SmtpSocket>
close?: () => Promise<void> | void
}

Options passed to ResendAdapter.

type ResendAdapterOptions = {
apiKey: string
apiBaseUrl?: string
fetch?: ResendFetch
limits?: EmailAttachmentLimits
userAgent?: string
}

Type: string

Resend API Key.

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

Custom API base URL override.

Type: ResendFetch

Custom fetch implementation. If omitted, uses the global fetch of the current environment.

Type: EmailAttachmentLimits

Attachment limits.


Options passed to SendGridAdapter.

type SendGridAdapterOptions = {
apiKey: string
apiBaseUrl?: string
fetch?: SendGridFetch
limits?: EmailAttachmentLimits
userAgent?: string
}

Type: string

SendGrid API Key (Bearer Token).

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

Custom API base URL override.


Options passed to PostmarkAdapter.

type PostmarkAdapterOptions = {
serverToken: string
apiBaseUrl?: string
fetch?: PostmarkFetch
limits?: EmailAttachmentLimits
messageStream?: string
tag?: string
trackLinks?: 'HtmlAndText' | 'HtmlOnly' | 'None' | 'TextOnly'
trackOpens?: boolean
userAgent?: string
}

Type: string

Postmark Server Token.

Type: string

Specifies the Postmark Message Stream ID to send through (e.g., 'outbound').

Type: string

Default category/tag for emails sent via this adapter.

Section titled “trackLinks / trackOpens ”

Enable link tracking or open tracking behavior at the adapter level.


Options passed to MailgunAdapter.

type MailgunAdapterOptions = {
apiKey: string
domain: string
apiBaseUrl?: string
fetch?: MailgunFetch
limits?: EmailAttachmentLimits
userAgent?: string
}

Type: string

Mailgun API key.

Type: string

Mailgun verified sending domain (e.g., 'mg.example.com').

Type: string · Default: 'https://api.mailgun.net'

For EU region domains, set this to 'https://api.eu.mailgun.net'.


Options passed to CloudflareEmailAdapter.

type CloudflareEmailAdapterOptions = {
connector: CloudflareEmailConnector
limits?: EmailAttachmentLimits
}

Type: CloudflareEmailConnector

Connector targeting the specific Cloudflare infrastructure.

  • RESTConnector({ accountId, apiToken }): Calls the Cloudflare Email REST API.
  • WorkersConnector({ bindingName }): Sends through a native Cloudflare Workers Email Routing binding (default binding name is 'EMAIL').

CloudflareEmailAdapter requires a connector implementing the CloudflareEmailConnector interface.

type CloudflareEmailConnector = {
send(
request: CloudflareEmailConnectorRequest,
): CloudflareEmailConnectorResult | Promise<CloudflareEmailConnectorResult>
}

Options for configuring the RESTConnector:

type CloudflareEmailRestConnectorOptions = {
accountId: string
apiBaseUrl?: string
apiToken: string
fetch?: CloudflareEmailFetch
}

Options for configuring the WorkersConnector:

type CloudflareEmailWorkersConnectorOptions = {
bindingName?: string
}