Refactoring of bulk email sending