Updates to email sending code