My NodeJS application uses nodeMailer
to send out emails to clients.
I'm trying to create an autoresponder-like function, where I:
- Send the first email to a user immediately
- Send the second email to the user after 24 more hours
- Send the third email to the user after 24 more hours
- 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.