Modified code for sendMail