sendEmail function is modified to allow send emails to multiple users