Обещание. Все, чтобы отправить электронные письма

const users = [
  {
    "name": "User 1",
    "email": "user1@gmail.com"
  },
  {
    "name": "user 2",
    "email": "user2@gmail.com"
  }
];


const sendEmailToUser = async (user) => {
   const data = {
      from: 'example@from.com',
      to: 'example@reciever.com',
      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