modified sendemail func