Refactored email sending