simplesmtp: Simple SMTP Server and Client Module

0.3.35 · abandoned · verified Tue Apr 21

simplesmtp is a Node.js module designed for creating custom SMTP servers and clients, primarily targeting older Node.js environments (v0.6 to v0.8+). The package, currently at version 0.3.35, is explicitly deprecated and no longer maintained. It was developed without Node.js v0.10 streams, indicating significant compatibility challenges with Node.js v0.12 and newer versions. While it offers basic SMTP functionality suitable for integration testing, it lacks active development, security updates, and modern features. Users are strongly advised to migrate to modern alternatives like `smtp-server` for server implementations, `smtp-connection` for client-side operations, or `Haraka` for full-featured SMTP applications, which offer better performance, security, and compatibility with current Node.js releases. There is no ongoing release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart sets up a basic `simplesmtp` server that listens on port 2525 (or `SMTP_PORT` if set), logs incoming email metadata, pipes the email body to standard output, and then accepts the message.

const simplesmtp = require('simplesmtp');

const PORT = process.env.SMTP_PORT || 2525;

simplesmtp.createSimpleServer({
  SMTPBanner: "My Test SMTP Server",
  debug: true
}, function(req) {
  console.log(`[simplesmtp] New message from: ${req.from}`);
  console.log(`[simplesmtp] To: ${req.to.join(', ')}`);
  console.log(`[simplesmtp] Host: ${req.host}`);
  console.log(`[simplesmtp] Client IP: ${req.remoteAddress}`);

  // Pipe the incoming email data to stdout
  console.log('\n--- Email Body Start ---');
  req.pipe(process.stdout);
  req.on('end', () => {
    console.log('\n--- Email Body End ---');
    // Accept the message after processing
    req.accept();
    console.log(`[simplesmtp] Message accepted from ${req.from}`);
  });
}).listen(PORT, function() {
  console.log(`[simplesmtp] Simple SMTP server listening on port ${PORT}`);
  console.log('Send an email to this server (e.g., via telnet: `telnet localhost 2525`, then SMTP commands like `MAIL FROM:<test@example.com>`, `RCPT TO:<recipient@example.com>`, `DATA`, `Subject: Test\n\nHello world!\n.`)');
});

view raw JSON →