Updated code to send mail