send_email error logging improvement