Refactor email notification code as minor fix for integration with Notification settings UI