Registry / storage / haraka-plugin-mongodb

haraka-plugin-mongodb

JSON →
library1.8.6jsnpmunverified

A plugin for the Haraka SMTP server that stores incoming and outgoing emails in MongoDB, with attachments saved to disk. Current stable version is 1.8.6, actively maintained by Helpmonks, supporting high throughput (500k+ emails/day). Key differentiators: built-in attachment content type/name filtering, inline image conversion (to base64 or path), connection string support, and optional attachment path health checks. Compatible with mailparser and tnef for winmail.dat handling.

npm install haraka-plugin-mongodb
INSTALL
IMPORT
SIG · HARAKA-PLUGIN-MONG
H
haraka-plugin-mongodb
storagejavascriptv1.8.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const plugin = require('haraka-plugin-mongodb');
import plugin from 'haraka-plugin-mongodb'
CommonJS-only plugin; no ESM package.json exports, so import will fail.
MongoDBQueue
const { MongoDBQueue } = require('haraka-plugin-mongodb');
const { Queue } = require('haraka-plugin-mongodb')
Named export is MongoDBQueue, not Queue.
MongoDBDelivery
const { MongoDBDelivery } = require('haraka-plugin-mongodb');
const { MongoDBQueue } = require('haraka-plugin-mongodb');
MongoDBDelivery is a separate export for delivery results. Using Queue by mistake.

Shows configuration setup and plugin registration for storing emails in MongoDB.

// In Haraka config/mongodb.ini: [MongoDB] host=localhost port=27017 db=haraka user=haraka password=secret string= [Collections] queue=emails delivery=outgoing // Then in Haraka config/plugins: add 'haraka-plugin-mongodb' // Minimal installation: // cd /path/to/haraka && npm install haraka-plugin-mongodb // cp node_modules/haraka-plugin-mongodb/config/mongodb.ini config/
Debug
Known issues
gotchaOn some systems, missing build tools (python2, make, cmake, g++) can cause native module compilation failures during npm install.
fix
Install build-essentials: apt install python2 make cmake g++ build-essentials
affects: *
gotchawinmail.dat (TNEF) files require the external tnef command; without it, attachments from Outlook won't be stored.
fix
Install tnef: apt install tnef
affects: *
gotchaIf using a mount point for attachments (e.g., Ceph/Gluster), the directory may become unavailable. Set path_check to monitor parent directory, not attachment folder itself.
fix
Set path_check = /parent/path (not attachment dir) in mongodb.ini
affects: >=1.5.5
breakingPrior to 1.6.5, there was no limit for incoming emails; could cause unbounded storage.
fix
Upgrade to 1.6.5+ and configure max_incoming option
affects: <1.6.5
deprecatedUsing host/port/user/password in config is legacy; connection string is recommended since 1.6.2.
fix
Set string in [MongoDB] section to a MongoDB connection URI
affects: >=1.6.2
Errors
Common errors & fixes
Error: Cannot find module 'haraka-plugin-mongodb'
Plugin not installed or path not correct in Haraka config/plugins
fix
Run npm install haraka-plugin-mongodb in the Haraka directory. Ensure plugins file includes 'haraka-plugin-mongodb' without .js extension.
MongoNetworkError: failed to connect to server [localhost:27017] on first connect
MongoDB not running or connection string wrong
fix
Start MongoDB service or correct the host/port/string in mongodb.ini.
TypeError: Cannot read property 'path' of undefined
Attachment path not set in config or directory doesn't exist
fix
Set attachment_path in [Attachments] section of mongodb.ini to an absolute path that exists and is writable.
Upgrade
Version history
1.8.6latest on npm
Audit
Dependencies
mongodbrequiredMongoDB driver for database connection
harakarequiredPlugin for Haraka SMTP server
mailparserrequiredEmail parsing
Agent activity
20 hits · last 30 days
node
20
Resources
haraka-plugin-mongodb — npm install haraka-plugin-mongodb · libregistry