Is there a way to schedule a mail? - node.js

I need to send emails every day and deliver them at a specific time.
Eg. I m calling the function at 1 am every day because no one uses the app at that time and I want emails to be delivered at 8 am the same day.
How can I achieve this by using nodemailer SMTP ?

Related

Algorithm to trigger bulk events by schedule

I'd like to create a web app that allows users to do email outreach, but I'm having trouble with a good solution.
I'd like each user to be able to send 100 emails per day, which would be configurable during certain times, e.g. 6 am to 10 am. I'm able to determine a delivery schedule per user (based on times that they configure), but b/c users can change their email schedules at any time, I'd have to reconfigure the order of processing.
Is there a queue type in Redis (for instance) that triggers by time?
Or a way to trigger events on a schedule in nodejs that's scalable?
There is a Redis feature: Keyspace notifications, which allow clients to subscribe to Pub/Sub channels in order to receive redis events( an example event is a"key expiry" event).
Documentation: http://redis.io/topics/notifications
For your use case, you can maybe use the "key expiry" event.

Schedule mail based on condition

I need to schedule a mail every 6 hours whenever the user's balance falls below a threshold. I'm trying to use node-cron package but everytime my server restarts, I'm sure it will start rescheduling and I don't want that to happen.

Sending email through Redis Simple Message Queue

I have to send email to 10 users in my app but I have to send them email separately . I am using loopback framework and for sending email and rsmq library
I have two approaches in mind for sending email
Approach 1
I should pass an array of emails to one message in the queue producer and in the queue listener I should iterate that array of email and send email one by one
Approach 2
I should pass separate message in the queue producer for every user to send email
Which approach is better and why ?
In Message Queuing, it is good to send one processable entry as one message to queue.
Reason Why:
In case you split the email sender into muliple functions, say for example after sending email, you need to update some log, update email count or anything (other example may suit well to explain), then every email needs to be proceeded independently by different functions.
Reason Why Not:
In case of batch processing, you may need to maintain no of emails per message and it exceed you need to write logic to split into batchee
Failure in processing of one message in middle may fail sending the rest of emails in same message.

How to send Email based on date in database using nodejs

Im having bulk of data in database with column scheduling date In which Im having date for mailing.Once the server start it will automatically send mail to the person based on scheduled time in database
you can save the scheduled time and email address into mongodb,and you can use this about cron job .

Architecture for "Sending Batch Email every midnight on AWS"

We have a Nodejs server running on an AWS EC2 instance with MongoDB at the backend. We need to send email notifications to our users depending on certain time-specific criteria.
The simplest way is to setup another instance and run a cron job on it every midnight. Go through all users one by one and dispatch emails if they fit the criteria.
This seems to be a pretty non-optimal solution as we have thousands of users. Is there any other way of doing this?

Resources