1.0.23 • Published 2 years ago

rabbitmq-email-manager v1.0.23

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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
      },
    });
1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago