Refactored email plugin to new model, tested