Skip to main content

Welcome to smtp-server

smtp-server is a powerful Node.js library for creating custom SMTP and LMTP server instances on the fly. Built by the team behind Nodemailer, it provides a flexible and extensible foundation for email infrastructure.

Why smtp-server?

Full Protocol Control

Complete control over SMTP/LMTP protocol handling with customizable command processing and authentication flows.

Enterprise Ready

Production-tested features including TLS/STARTTLS support, multiple authentication methods, and proxy protocol support.

Developer Friendly

Simple, event-driven API with comprehensive hooks for validation, authentication, and message processing.

High Performance

Stream-based message handling for efficient processing of large emails with configurable size limits.

Key Features

  • Multiple Protocol Support: Create both SMTP and LMTP servers
  • Flexible Authentication: Built-in support for PLAIN, LOGIN, and CRAM-MD5 authentication methods
  • TLS/STARTTLS: Full support for secure connections with SNI (Server Name Indication)
  • Proxy Protocol: PROXY protocol support for deployment behind load balancers
  • Stream Processing: Efficient handling of large messages using Node.js streams
  • Extensible Validation: Custom validation hooks for sender, recipient, and message content
  • Advanced Features: DSN (Delivery Status Notifications), ENHANCEDSTATUSCODES, REQUIRETLS, and more

Quick Example

Here’s a minimal SMTP server that logs received messages:
const { SMTPServer } = require('smtp-server');

const server = new SMTPServer({
  logger: true,
  disabledCommands: ['STARTTLS', 'AUTH'],
  onData(stream, session, callback) {
    stream.pipe(process.stdout); // Output message to console
    stream.on('end', callback);
  }
});

server.listen(2525);
The server listens on port 2525 by default in examples to avoid requiring root privileges (ports below 1024 require elevated permissions).

Use Cases

1

Testing & Development

Create local SMTP servers for testing email functionality in your applications without sending real emails.
2

Email Processing Pipelines

Build custom email processing systems with validation, filtering, and routing logic.
3

Webhook Bridges

Convert incoming emails into webhooks or API calls for integration with other services.
4

Email Archiving

Implement custom archiving solutions with full control over message storage and indexing.

Next Steps

Installation

Get started by installing smtp-server in your project

Quick Start

Build your first SMTP server in minutes

API Reference

Explore the complete API documentation

Core Concepts

Learn key concepts and configuration

System Requirements

smtp-server requires Node.js 18.18.0 or higher. Make sure your environment meets this requirement before installation.

Community & Support

smtp-server is part of the Nodemailer ecosystem and is actively maintained:
Looking for a full email sending solution? Check out Nodemailer for SMTP client functionality.

Build docs developers (and LLMs) love