Skip to main content
zerotal

Documentation


Documentation / @zerotal/notifications / SmtpDriver

Class: SmtpDriver

Defined in: notifications/src/drivers/SmtpDriver.ts:23

SMTP driver — raw TCP via Bun.connect(), with TLS.

Three transport modes, chosen by secure and what the server advertises:

  • secure: true — implicit TLS from the first byte (SMTPS, usually port 465).
  • secure: false on a server advertising STARTTLS — connects in the clear, then upgrades before authenticating (submission, usually port 587).
  • secure: false on a server without STARTTLS — stays plaintext. Credentials are refused in this mode unless allowInsecureAuth is set, because AUTH LOGIN is base64, not encryption.

Every reply is parsed and its status code checked, so a rejected recipient or a failed authentication raises SmtpResponseError instead of being mistaken for a successful send.

Implements

Constructors

Constructor

new SmtpDriver(_host, _port, _username, _password, _secure?, _options?): SmtpDriver

Defined in: notifications/src/drivers/SmtpDriver.ts:24

Parameters

_host

string

_port

number

_username

string

_password

string

_secure?

boolean = false

_options?
allowInsecureAuth?

boolean

Permit AUTH over an unencrypted connection. Off by default.

rejectUnauthorized?

boolean

Reject servers presenting an untrusted certificate. Default: true.

timeoutMs?

number

Per-reply timeout in milliseconds. Default: 30000.

clientName?

string

Name sent in EHLO. Default: "zerotal".

Returns

SmtpDriver

Methods

send()

send(message): Promise<void>

Defined in: notifications/src/drivers/SmtpDriver.ts:42

Parameters

message

MailPayload

Returns

Promise<void>

Implementation of

MailDriver.send