Promise.Tall para enviar e -mails

const users = [
  {
    "name": "User 1",
    "email": "[email protected]"
  },
  {
    "name": "user 2",
    "email": "[email protected]"
  }
];


const sendEmailToUser = async (user) => {
   const data = {
      from: '[email protected]',
      to: '[email protected]',
      subject: 'Sample subject',
      html: 'await email()'
   };
   await mailgun.messages().send(data);              
};

(async () => {
    const sendEmailPromises = [];

    for(const user of users) {
        // Start sending all emails
        sendEmailPromises.push(sendEmailToUser(user));
    }

    // Wait for all emails to be sent
    await Promise.all(sendEmailPromises);

    // Do something
})()
Fierce Fly