refactor sending email