Save and use email values
Move mail specific functions and add basic test for alert emails