This Node.js Email Service Backend is a multi-tenant SaaS application designed to handle incoming and outgoing emails for multiple clients. Each client can securely store their IMAP and SMTP credentials, allowing the service to receive live emails, parse them, store them in a database, and forward them to client-defined webhooks. The service also supports sending emails using client SMTP accounts.
The service bootstraps by fetching all registered clients from the database and initializing IMAP connections for each. Incoming emails are parsed using mailparser, stored in MongoDB, and forwarded to the specified webhook endpoint along with attachments. Webhook requests are secured via a basic authentication token, ensuring that only authorized clients can receive forwarded emails.
Key features include:
- Multi-tenant support with isolated client credentials.
- Real-time email listening and parsing.
- Database storage for all incoming emails.
- Forwarding emails to webhooks with attachments.
- Secure webhook communication using basic authentication.
- SMTP support for sending emails on behalf of clients.
The system is designed to be extensible, with future support planned for MinIO attachment storage, per-client authentication methods, and enhanced webhook management.
This guide will walk you through the steps to set up Email Notification on Windows, Linux, and macOS.
- typescript 5.6.3 or above
- node 20 LTS or above
- imap 0.8.19 or above
- express 4.21.1 or above
- mailparser 3.7.1 or above
- mongoose 8.8.1 or above
- multer 1.4.5-lts.1 or above
- pino 9.5.0 or above
- pino-http 10.3.0 or above
- pino-pretty 13.0.0 or above
- pino-roll 2.2.0 or above
- zod 3.23.8 or above
- docker
Node.js is an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. To install it:
- Download NodeJS v20.18.3 (LTS) (or above) from the NodeJS website.
- Run the installer and follow the on-screen instructions.
Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. To install it:
- Download docker desktop from Docker Website.
- Run the installer and follow the on-screen instructions.
MongoDB is a document database. It stores data in a type of JSON format called BSON. To Install it:
- Download Mongodb and mongoshell from Mongodb Website.
- Run the installers and follow the on-screen instructions.
Follow the instructions to install NodeJS 20 from the official NodeJS documentation.
Follow the instructions to install Docker from the official Docker documentation.
Follow the instructions to install Mongodb and mongoshell from the official Mongodb documentation.
Clone the Notification Module repository to your local machine:
git clone gitlab-logicabeans.com:username/notification-module.git
Change to the project directory: cd notification-module
Use Node or Bun to install the required dependencies:
- npm install or bun install
Copy the example environment file and configure it:
- cp .env.sample
- create the .env file and update the necessary mongodb and imap configurations based on your setup.
To run the app development server, execute:
npm run dev The application should now be accessible at http://localhost:<ENV_PORT>.
To run the app inside a container, execute:
- docker compose up --build -d
- Fork the repository.
- Create a new branch (git checkout -b FD-:).
- Commit changes and push. (git commit -m "FD-:: ")
- Open a Pull Request.
https://http://localhost:<ENV_PORT>