Haraka SMTP Server

3.1.5 · active · verified Sun Apr 19

Haraka is a highly scalable Node.js email server designed for modularity and high performance. It features a robust plugin architecture, enabling developers to easily extend its functionality for tasks such as spam protection, custom routing, and authentication. Haraka excels as a filtering Message Transfer Agent (MTA) or a Mail Submission Agent (MSA) on port 587 with authentication, complementing traditional mail systems like Postfix or Exchange without attempting to be a mail store or IMAP server. The current stable version is 3.1.5, with frequent releases addressing bug fixes, dependency updates, and minor enhancements. Its key differentiators include an asynchronous, event-driven design for speed, excellent built-in spam protection capabilities through plugins, and an easily extensible system for handling complex mail flow scenarios with minimal code.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the typical workflow for installing Haraka globally, initializing a new server instance, and preparing it for startup as an SMTP server, including notes on configuration and permissions.

#!/usr/bin/env node

// 1. Install Haraka globally (recommended for CLI usage)
// npm install -g Haraka

// 2. Create a directory for your Haraka instance and initialize it
const { execSync } = require('child_process');
const path = require('path');
const fs = require('fs');

const instancePath = path.join(__dirname, 'haraka_test_instance');

console.log(`Initializing Haraka instance at ${instancePath}...`);
execSync(`haraka -i ${instancePath}`, { stdio: 'inherit' });

// 3. (Optional) Configure accepted domains (e.g., 'example.com')
//    Edit config/host_list within haraka_test_instance to add your domain.
//    For example: echo 'example.com' > ${instancePath}/config/host_list

// 4. (Optional) Configure outbound forwarding (smtp_forward plugin is default)
//    Edit config/smtp_forward.ini to specify destination SMTP server.
//    Example: echo '[main]\nforward_to=localhost:25000' > ${instancePath}/config/smtp_forward.ini

// 5. Start Haraka (requires root permissions for ports below 1024, like 25)
console.log(`Starting Haraka server (may require sudo for port 25)...`);
console.log(`To stop, use Ctrl+C or kill the process.`);
// In a real scenario, you'd run this from your terminal with 'sudo haraka -c haraka_test_instance'
// For demonstration, we'll just log the command.
console.log(`
Run this command in your terminal: sudo haraka -c ${instancePath}`);

// Example of waiting and then showing how to potentially stop for a script
// In a real application, you'd use a process manager like PM2.
// setTimeout(() => {
//   console.log('Demonstration complete. Exiting.');
//   // In a real script, you'd send a signal to stop the process.
// }, 15000);

view raw JSON →