[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/notifications](../README) / SmtpDriver

# Class: SmtpDriver

Defined in: [notifications/src/drivers/SmtpDriver.ts:23](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/drivers/SmtpDriver.ts#L23)

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](SmtpResponseError) instead of being
mistaken for a successful send.

## Implements

- [`MailDriver`](../interfaces/MailDriver)

## Constructors

### Constructor

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

Defined in: [notifications/src/drivers/SmtpDriver.ts:24](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/drivers/SmtpDriver.ts#L24)

#### 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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/drivers/SmtpDriver.ts#L42)

#### Parameters

##### message

[`MailPayload`](../interfaces/MailPayload)

#### Returns

`Promise`\<`void`\>

#### Implementation of

[`MailDriver`](../interfaces/MailDriver).[`send`](../interfaces/MailDriver#send)
