total rewrite of all the email stuff, hopefully a lot of bugs got fixed in the process