STARTTLS (port 587)
STARTTLS allows clients to upgrade a plain TCP connection to TLS:starttls-server.ts
needsUpgrade: true means the server will reject AUTH and MAIL commands until the client runs STARTTLS.Implicit TLS (port 465)
Implicit TLS starts encryption immediately upon connection:implicit-tls-server.ts
Generating self-signed certificates
For development, generate a self-signed certificate:Using Let’s Encrypt certificates
Load production certificates from disk:Hot-reloading certificates
Rotate certificates without restarting:Inspecting the TLS connection
Use theonSecure callback to inspect TLS details:
Client certificate validation
Require clients to present a valid certificate:SNI (Server Name Indication)
Serve different certificates for different domains:TLS options reference
string | Buffer
required
Private key in PEM format
string | Buffer
required
Certificate in PEM format
string | Buffer | Array<string | Buffer>
Certificate authority bundle for client cert verification
boolean
default:"false"
Start in implicit TLS mode (true) or allow STARTTLS (false)
boolean
default:"false"
Require STARTTLS before AUTH and MAIL commands
boolean
default:"false"
Request a client certificate during TLS handshake
boolean
default:"false"
Reject clients with invalid or unverifiable certificates
string
Minimum TLS version (e.g.,
"TLSv1.2")string
Maximum TLS version (e.g.,
"TLSv1.3")Record<string, TLSOptions>
Per-hostname TLS configuration for SNI
Testing TLS connections
- STARTTLS
- Implicit TLS
Next steps
TLS guide
Learn more about TLS configuration
Authentication
Add authentication to your server
Configuration reference
Explore all TLS options
Callbacks reference
Learn about onSecure callback