Refactoring mail config to service layer.