smtp refactor