refactoring email sending