Fix error handling in email sending.