First shot at email code

It should work. If not, I have ideas on what might cause problems.