I am working on a project and i want to send emails to users by looping through an array of emails on my server.
The items of the array (users emails) are quite much and i would like to send them emails batch by batch.
The sendMail
function is called within the loop. It works now but I want to rewrite it in such a way that it will pause for 60 seconds after every 10 sends.
here is my code.
for (var i = 0; i < unsetUsers.length; i++) {
var user = unsetUsers[i];
var obj = {
---
};
//send mail to each one of them
sendSetUpMail(obj);
}
Can this be achived using for loop
and setTimeout
or setInterval