# smtp-server

> Create custom SMTP servers on the fly

Latest version **3.19.12** (published 2026-09-12) · MIT-0 license · 0 weekly downloads

## Install

```sh
npm install smtp-server
pnpm add smtp-server
yarn add smtp-server
bun add smtp-server
```

## Health

**Score 68/100 (B)** — status: active.

Positive: has types package; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.19.12 |
| Published | 2026-09-12 |
| First published | 2015-02-16 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | separate (@types/smtp-server) |
| Module format | CommonJS |
| Node | >=20.0.0 |
| Dependencies | 3 |
| Unpacked size | 333.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 914 |
| Author | Andris Reinman |
| Maintainers | andris |
| Keywords | SMTP |

## Links

- npm: https://www.npmjs.com/package/smtp-server
- Repository: https://github.com/nodemailer/smtp-server
- Homepage: https://github.com/nodemailer/smtp-server#readme
- Issues: https://github.com/nodemailer/smtp-server/issues
- npm.io page: https://npm.io/package/smtp-server

## Dependencies (3)

- [nodemailer](https://npm.io/package/nodemailer.md) 10.0.9
- [punycode.js](https://npm.io/package/punycode.js.md) 2.3.1
- [ipv6-normalize](https://npm.io/package/ipv6-normalize.md) 1.0.1

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 3.19.12 (latest) — 2026-09-12
- 1.9.0-beta.0 (beta) — 2016-02-05
- 3.19.11 — 2026-09-11
- 3.19.10 — 2026-09-10
- 3.19.9 — 2026-09-07
- 3.19.8 — 2026-09-06
- 3.19.7 — 2026-09-02
- 3.19.6 — 2026-09-01
- 3.19.5 — 2026-08-31
- 3.19.4 — 2026-08-27
- 3.19.3 — 2026-08-07
- 3.19.2 — 2026-07-05
- 3.19.1 — 2026-06-19
- 3.19.0 — 2026-06-15
- 3.18.5 — 2026-05-29
- … 79 more at https://npm.io/package/smtp-server/versions

## README

# smtp-server

![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png)

Node.JS module for creating SMTP and LMTP server instances on the fly.

See [smtp-server homepage](https://nodemailer.com/extras/smtp-server/) for documentation and terms.

## Using the SIZE extension

Set the `size` option to advertise a maximum message size to clients. Declared sizes in `MAIL FROM:<addr> SIZE=nnn` parameters are checked against the limit, but the actual transfer size is not enforced by the server itself — message data is streamed to the application, so it is up to the application to decide what to do with an oversized message. Check `stream.sizeExceeded` in your `onData` handler to detect oversized messages:

```js
const server = new SMTPServer({
    size: 1024 * 1024, // 1 MiB limit
    onData(stream, session, callback) {
        stream.on('end', () => {
            if (stream.sizeExceeded) {
                const err = new Error('Message too large');
                err.responseCode = 552;
                return callback(err);
            }
            callback(null, 'OK');
        });
        stream.resume(); // Consume the stream
    }
});
```

The `sizeExceeded` flag and the `byteLength` byte counter on the data stream are updated in real time while the message is being received, so a handler that wants to stop an oversized transfer early can also check the flag from a `data` event instead of waiting for `end`.

---
_Source: https://npm.io/package/smtp-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
