Skip to main content
Every callback receives a session object representing the current connection state.

SMTPSession

The main session object passed to all callbacks.
string
Unique connection identifier.
boolean
true if the connection is currently using TLS.
string | undefined
SNI hostname from the TLS handshake (if TLS is active).
string
Server IP address.
number
Server port.
string
Client IP address.
number
Client port.
string
Reverse-DNS hostname of the client. Falls back to "[remoteAddress]" if lookup fails or is disabled.
string
Hostname the client claimed in HELO/EHLO.
string
The first command the client sent: "HELO", "EHLO", or "LHLO".
string
SMTP transmission type string, e.g. "ESMTPSA" (Extended SMTP with Auth).
TLSCipherInfo | false
TLS cipher info after TLS is established, false before. See TLSCipherInfo below.
unknown
Value passed as user in a successful onAuth response. Use this to track the authenticated user.
number
Number of completed mail transactions on this connection (incremented after each successful onData).
SMTPEnvelope
Current mail envelope. See SMTPEnvelope below.
Map<string, string | false>
XCLIENT header values (when useXClient: true).
Map<string, string | false>
XFORWARD header values (when useXForward: true).

TLSCipherInfo

TLS cipher and protocol information, available after TLS handshake.
string
OpenSSL cipher name (e.g. "ECDHE-RSA-AES128-GCM-SHA256").
string | undefined
IANA cipher name.
string | undefined
TLS protocol version (e.g. "TLSv1.3").

Example


SMTPEnvelope

Available as session.envelope. Populated progressively as the client sends MAIL FROM and RCPT TO commands.
SMTPAddress | false
Sender address from MAIL FROM, or false before MAIL FROM is received.
SMTPAddress[]
Array of accepted recipient addresses from RCPT TO.
'7bit' | '8bitmime'
Body encoding declared by the client.
boolean
true if the client declared SMTPUTF8 support.
boolean
true if the client sent REQUIRETLS (RFC 8689).
DSNEnvelope | undefined
DSN envelope parameters. See DSNEnvelope below.

Example


SMTPAddress

Represents an email address from MAIL FROM or RCPT TO commands.
string
The email address (e.g. "alice@example.com").
SMTPAddressArgs | false
ESMTP parameters from the command, or false if none. See SMTPAddressArgs below.
DSNRcpt | undefined
Per-recipient DSN parameters. See DSNRcpt below.

SMTPAddressArgs

ESMTP parameters parsed from the MAIL FROM or RCPT TO command.
string | undefined
Declared message size in bytes.
string | undefined
Body type: "7BIT" or "8BITMIME".
true | undefined
UTF-8 support flag.
true | undefined
TLS-required flag (RFC 8689).
string | undefined
DSN return type ("FULL" or "HDRS").
string | undefined
DSN envelope ID.
string | undefined
DSN notification conditions (comma-separated, e.g. "SUCCESS,FAILURE").
string | undefined
DSN original recipient address.
string | true | undefined
Any unrecognized ESMTP parameter is also available as a string or true.

Example


DSNEnvelope

DSN (Delivery Status Notification) parameters from the envelope.
'FULL' | 'HDRS' | null
Return type requested by the client:
  • "FULL": Return full message in DSN
  • "HDRS": Return headers only
  • null: No preference specified
string | null
Envelope identifier for tracking DSN reports.

DSNRcpt

Per-recipient DSN parameters.
string[] | undefined
DSN notification conditions (e.g. ["SUCCESS", "FAILURE", "DELAY"]).
string | undefined
Original recipient address (for forwarding scenarios).

Example


DataStream

A ReadableStream<Uint8Array> with extra metadata set after the stream closes.
number | undefined
Total bytes received (available after stream closes).
boolean | undefined
true if the message exceeded the configured size limit.

Example


Complete Example