refactored email settings and test