mail setting functionality extracted from spree