refactor emailhandler into it's own module