added an error handler and the mail service