Skip to main content
Pass options to the SMTPServer constructor:

Connection

boolean
default:false
Start in implicit TLS mode (port 465 style). When false, STARTTLS is offered instead.
boolean
default:false
Reject AUTH and MAIL until the client completes STARTTLS.
string
default:"system hostname"
Server hostname included in the 220 greeting and EHLO response.
string
default:""
Extra text appended to the 220 greeting line.
boolean
default:false
Use LMTP instead of SMTP. Clients open with LHLO and onData may return per-recipient responses.
string
default:"%s Nice to meet you, %s"
Format string for the HELO/EHLO response. First %s is the server name, second is the client hostname.

Authentication

string[]
default:["PLAIN","LOGIN"]
SASL methods advertised in EHLO. Supported values: "PLAIN", "LOGIN", "CRAM-MD5", "XOAUTH2".
boolean
default:false
Allow clients to skip AUTH entirely.
boolean
default:false
Allow AUTH over a plain (non-TLS) connection.
string
Custom error message for the 530 response when auth is required.
By default, AUTH is disabled over non-TLS connections. Set allowInsecureAuth: true to permit plaintext authentication.

Capability Flags

These options hide extensions from the EHLO response. The extension still works — it is just not advertised.
boolean
default:false
Hide STARTTLS from EHLO.
boolean
default:false
Hide the SIZE extension.
boolean
default:false
Hide PIPELINING.
boolean
default:true
Hide DSN (Delivery Status Notification).
boolean
default:true
Hide ENHANCEDSTATUSCODES.
boolean
default:true
Hide REQUIRETLS.
boolean
default:false
Hide 8BITMIME.
boolean
default:false
Hide SMTPUTF8.
string[]
default:[]
Block specific SMTP commands entirely (e.g. ["AUTH", "STARTTLS"]).

Limits

number
Maximum message size in bytes. Advertised via the SIZE extension. The onData stream’s sizeExceeded flag is set when the limit is hit.
number
Maximum number of simultaneous connections. New connections are rejected with 421 when the limit is reached.
number
default:60000
Milliseconds of inactivity before an idle connection is closed.
number
default:30000
Milliseconds to wait for connections to drain during server.close(). Connections still open after this are forcibly terminated.
number | false
default:10
Maximum commands allowed before authentication. Set to false to disable the limit.
Setting maxAllowedUnauthenticatedCommands to false may expose your server to abuse. Use with caution.

Proxy / X-headers

boolean
default:false
Trust Postfix XCLIENT headers. When enabled, session.xClient is populated.
boolean
default:false
Trust Postfix XFORWARD headers. When enabled, session.xForward is populated.
boolean | string[]
default:false
Parse HAProxy PROXY protocol header. Pass an array of trusted proxy IP addresses to restrict which proxies are trusted.
Only enable proxy headers if you trust the upstream proxy. Malicious clients can forge these headers.

DNS

boolean
default:false
Skip reverse DNS lookup on new connections. When false, session.clientHostname is resolved from the client’s IP.
object
Custom DNS resolver. Must implement reverse(ip, callback) with the same signature as dns.reverse.

TLS

All standard TLS options. See the TLS & STARTTLS guide for usage examples.
string | Buffer
Private key in PEM format.
string | Buffer
Certificate in PEM format.
string | Buffer | Array
CA bundle for client certificate verification.
boolean
Request a client certificate during TLS handshake.
boolean
Reject clients with invalid or unverifiable certificates.
string
Minimum TLS version string (e.g. "TLSv1.2").
string
Maximum TLS version string.
Record<string, TLSOptions> | Map<string, TLSOptions>
Per-hostname TLS configuration for SNI (Server Name Indication).
If no TLS options are provided, the server uses a default self-signed certificate for development.

Callbacks

All lifecycle callbacks can be set as constructor options. See Callbacks for full signatures and examples.
OnConnectCallback
Called on new connection.
OnSecureCallback
Called after TLS handshake.
OnAuthCallback
Called on AUTH attempt.
OnMailFromCallback
Called on MAIL FROM.
OnRcptToCallback
Called on RCPT TO.
OnDataCallback
Called when DATA transfer begins.
OnCloseCallback
Called when connection closes.

Complete Example