def onError(error):
            if isinstance(error.value, SMTPDownException):
                respond_json_deferred({'message': str(error.value)}, request, status_code=503)
            else:
                log.error('error occurred while sending: %s' % error.getErrorMessage())
                respond_json_deferred({'message': 'an error occurred while sending'}, request, status_code=422)