As a developer, email sending is a recurent task across the projects.
Most part of time, you have to deal with open source libraries, to switch from a library to another accross the projects, with some particular implementations and / or behaviors.
As well, you can have a different need inside a same project just regarding the use case.
For example, you can still need to send an email to a developer when a particular event is fired, or send a transactionnal email to say welcome to a new user.
In the first case, a simple SMTP server can do the job internally.
In the second case, it's more efficient to rely to a web API, able to manage statistics, bouncing, DKIM, templating, ...
As well, you can need to deal with different providers at the same time. During a migration, for example.
Some months ago, I was wondering how to provide something flexible and consistent to deal with this kind of repetitive issue.
And I did it myself, because it was quite fun. ๐
All the cases described above - and some others - are covered by a light NPM package.
The main features are:
- Configuration based
- Agnostic appoach: same input, same output for all configurations
- Formalized transactions conventions
- Unlimited number of transporters inside the same project
- Support of different sending modes (SMTP and web API)
- Embeded view engine, stream or web API templates
There is Cliam, an agnostic and very flexible tool to deal with transactional email sending.
steve-lebleu / cliam
Agnostic transactional email sending in Node.js environment
Transactional emails with a kick
Agnostic transactional email sending in Node.js environment ๐ฅ ๐ช ๐
> Why ?
To improve and facilitate the implementation, flexibility and maintenance of transactional emailing tasks.
> Features
- Agnostic transactional email sending using web API or SMTP server. One input, one output.
- Multiple simultaneous transporters.
- Configuration based, not implementation based : easy switch between different modes.
- Normalized transactions events.
- Securized payloads.
- Customisable default templates.
> Table of contents
- Requirements
- Getting started
- Beneficiary use cases
- Supported web API providers
- Licence
- Documentation
> Requirements
- Node.js >= 18.19.0
- NPM >= 10.2.3
> Getting started
Install
> npm i cliam --save
Configure
Create a .cliamrc.js module on the root of your project.
> touch .cliamrc.js
Define a minimalist configuration in .cliamrc.js newly created:
module.exports = {
"sandbox": true,
"transporters": [
{
"id": "unique-transporter-key",
"auth": {
"username": process
โฆCurrently, following web api providers are supported: Mailgun, Mailjet, Brevo, Sendinblue, Sendgrid, Mandrill, Sparkpost, Mailsender and Postmark. Amazon SES and a lot of others should be integrated soon, but I prefer take the focus on some new features and to push more robustness before to embedd too much transporters.
Have a good dev, enjoy and feel free to use and to share ๐
Top comments (0)