How to use the aiosmtpd.const.DATA_TERM function in aiosmtpd

To help you get started, we’ve selected a few aiosmtpd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aiosmtpd / aiosmtpd / streams.py View on Github external
def read_data(self, max_len=None):
        """ Reads a dot-delimited SMTP DATA segment."""
        data_length = 0
        lines = []

        while True:
            line = yield from self.read_crlf_line(max_len=None)
            access_log.debug("Data line read: %r", line)

            if line == const.DATA_TERM:
                break

            if line.startswith(b'.'):
                line = line[1:]

            data_length += len(line)
            if max_len and data_length > max_len:
                access_log.error('Too much data: %i bytes', data_length)
                raise errors.TooMuchDataError()

            lines.append(line)

        result = const.LINE_TERM.join(lines)
        if max_len and len(result) >= max_len:
            raise errors.TooMuchDataError()