Added email notifications when errors occur.