fixed sendMail function