Improved error handling on email sending