-2

I am currently using nodemailer to send Email from my node.js application. What i am looking for is "something" that queues and schedules the sending of large number of Emails(500+ per user) by multiple users.

This should run as a separate process in background and must be triggered by my node.js application. Email sending should not affect my Node.Js application(server) from responding to requests.

I know the above statements seems more like a s/w requirement rather than a problem to fix but i need a robust solution.Please give a brief solution(i.e., what "somethings" to use).

Dheemanth Bhat
  • 4,269
  • 2
  • 21
  • 40
  • 1
    Here is an article you can check out. Triggering lambdas using SQS may be a way to go for you. https://cloudonaut.io/integrate-sqs-and-lambda-serverless-architecture-for-asynchronous-workloads/ –  Oct 12 '18 at 18:10
  • Very nice but these are 3rd party services(also not free i believe). I am looking for something to build on my own by using proper packages, that which can be scheduled, queued and triggered by my node.js app – Dheemanth Bhat Oct 12 '18 at 18:21
  • 2
    I'm pretty sure you get 1 million Amazon SQS requests for free each month as well as 1 million lambdas requests. Not really sure on the lambda requests tho, don't quote me. As far as actually sending the email from the lambda, you could still use whatever you choose. –  Oct 12 '18 at 18:27

1 Answers1

2

Create a lambda function to send one email only with your nodeMailer script.

In this lambda I would cache the mailer outside the actual exports function like:

const nodemailer = require('nodemailer');

exports.handler = (event, context, callback) => {

    // ...NodeMailer stuff

    callback(null, event)
};

Then trigger this lambda with an SQS event as seen here: SQS as an event source to trigger Lambda | Medium

You can add a message to the queue using the JS AWS-SDK from your node js app as seen here: Calling the sendMessage operation | AWS Docs

Shayan Shafiq
  • 1,447
  • 5
  • 18
  • 25