rabbitmq-email-manager
v1.0.23
Published
A light-weight helper class that uses amqplib to send emails via nodemailer. Note!! This is a personal module developed for code re-usability.
Downloads
5
Readme
A light-weight amqplib class helper to send emails via nodemailer.
This module was developed to help with code re-usability in a project.
If You find it helpful, by all means install and use.
Before you use, kindly pass a reference to amqplib client and nodemailer transporter, in the entry point of your app.
main.js
import { QueueManager } from "rabbitmq-email-manager";
import queue from "./queue";
import smtp from "./smtp";
import { QUEUE_EVENTS } from "./constants";
await QueueManager.init({
queueClient: queue.client,
smtpClient:smtp.client,
queue: QUEUE_EVENTS.name,
});
//If you want to consume published messages on same app
await QueueManager.consume({ logging:true });
controller.js
import { QueueManager } from "rabbitmq-email-manager";
await QueueManager.publish({
data: {
to: email,
from: {
name: process.env.SMTP_EMAIL_FROM_NAME,
address: process.env.SMTP_EMAIL_FROM,
},
subject: "Mail Subject",
bcc: [
process.env.SMTP_CUSTOMER_CARE_EMAIL,
process.env.SMTP_EMAIL_FROM,
],
html: mailHtml
},
});