1

My NodeJS application uses nodeMailer to send out emails to clients.

I'm trying to create an autoresponder-like function, where I:

  1. Send the first email to a user immediately
  2. Send the second email to the user after 24 more hours
  3. Send the third email to the user after 24 more hours
  4. Send the fourth email to the user after 24 more hours

According to the NodeJS docs, using setTimeout() isn't particularly accurate in Node - is there a better solution to use?

I'm a little weary of doing something like this, just because I don't want a 24-hour setTimeout() in case I restart my server and the timeout is cancelled.

Is there a better way to achieve this in Node? The only solution I can think of is to log each user to a database, log which emails have been sent and which haven't and have my server do the function every hour or so.

JVG
  • 20,198
  • 47
  • 132
  • 210

0 Answers0