Extendable framework for SMTP servers.
I was looking at ways to build a custom mail server in Node. The obvious first candidate was Haraka. Being mature and stable, as well as extendable, it looked like a perfect fit. Haraka relies heavily on all kinds of configuration files though, whereas I prefer the "code over configuration" approach that is more prevalent in the Node community.
Next I looked into Nodemailer's
smtp-server. This module meets all the low-level requirements for building mail servers in Node. What it doesn't do though, is define a standardized way to break things up in smaller, reusable functionalities. I wanted an extendable higher-level API on top of it, similar to web frameworks like Express and Fastify, but I couldn't find any. So I decided to build one myself.
npm install usemail
var usemail =var filter =var spf =var mail =var storage =
This example creates a basic mail server that stores the text of incoming messages in memory. First, before accepting the message, it validates the SPF records using
usemail-address-filter filters out all mails, except those sent to explicitly allowed recipients. Only when both those checks have passed, the incoming mail data is parsed and stored.
So far, the following Usemail plugins are available on
If you want to add your own to the list, feel free to open a PR!