简体   繁体   中英

How to handle multiple emails being sent with nodemailer without blocking main thread

I have an node application with multiple routes and all cases are being handled with asynchronous functions to handle them but I am looking forward for a logic/idea how to proceed when multiple emails are to be sent with respective email content like username, image, etc. with nodemailer (being iterated).

Basically I have an array/object which has all content to send each email address but if I allow to execute then that loop will block the main thread and thus next requests/tasks won't be able to achieve.

Looking forward to get some idea.

Thanks.

You can call your function after sending the response.

myController = (req, res, next) => {
   /* some code */

   res.send("OK");
   callMailServicesHere(myArray);

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM