Added emailing when an error happens