fixed error when sending emails