def dispatch(self, log_level=None, disconnect_after_delivery=True):

        if log_level is None:
            log_level = get_log_level()

        connection = None
        try:
            connection = connections[self.backend_alias or 'default']
            self.email_message(connection=connection).send()
            status = STATUS.sent
            message = ''
            exception_type = ''
        except Exception as e:
            status = STATUS.failed
            message = str(e)
            exception_type = type(e).__name__

        if connection and disconnect_after_delivery:
            connection.close()

        self.status = status
        self.save()

        # If log level is 0, log nothing, 1 logs only sending failures
        # and 2 means log both successes and failures
        if log_level == 1:
            if status == STATUS.failed:
                self.logs.create(status=status, message=message,
                                 exception_type=exception_type)
        elif log_level == 2:
            self.logs.create(status=status, message=message,
                             exception_type=exception_type)

        return status
Testing the PUT review-requests/<id>/draft/ API
dataset/ETHPy150Open ui/django-post_office/post_office/models.py/Email.dispatch--crossover with--dataset/ETHPy150Open reviewboard/reviewboard/reviewboard/webapi/tests/test_review_request_draft.py/ResourceTests.test_put_with_changedescription_text_type_plain