예제 #1
0
    def command_noop(self, arg):
        """Handles the ``NOOP`` SMTP command.

        - Raises a :class:`~bonzo.errors.BadArguments` when an argument is not
          received.
        """
        if arg:
            raise errors.BadArguments('NOOP')
        self.write_ok()
예제 #2
0
    def command_rset(self, arg):
        """Handles the ``RSET`` SMTP command.

        - Raises a :class:`~bonzo.errors.BadArguments` when an argument is not
          received.
        """
        if arg:
            raise errors.BadArguments('RSET')
        self.reset_arguments()
        self.write_ok()
예제 #3
0
    def command_helo(self, arg):
        """Handles the ``HELO`` SMTP command.

        - Raises a :class:`~bonzo.errors.BadArguments` error code when the
          network name of the connecting machine is not received.
        - Raises a :class:`~bonzo.errors.BadSequence` when a ``HELO`` command
          already was received.
        """
        if not arg:
            raise errors.BadArguments('HELO hostname')
        if self.__hostname:
            raise errors.BadSequence('Duplicate HELO/EHLO')
        self.__hostname = arg
        self.write('250 Hello %s' % self.remote_ip)
예제 #4
0
    def command_data(self, arg):
        """Handles the ``DATA`` SMTP command.

        - Raises a :class:`~bonzo.errors.BadSequence` when a ``RCPT`` command
          was not previously received.
        - Raises a :class:`~bonzo.errors.BadArguments` when an argument is not
          received.
        """
        if not self.__rcpt:
            raise errors.BadSequence('Error: need RCPT command')
        if arg:
            raise errors.BadArguments('DATA')
        self.__state = self.DATA
        self.write('354 End data with <CR><LF>.<CR><LF>',
                   read_until_delimiter='{0}.{0}'.format(CRLF))
예제 #5
0
    def command_rcpt(self, arg):
        """Handles the ``RCPT`` SMTP command.

        - Raises a :class:`~bonzo.errors.BadSequence` when a ``MAIL`` command
          was not previously received.
        - Raises a :class:`~bonzo.errors.BadArguments` when the ``to`` address
          is not received.
        """
        if not self.__mail:
            raise errors.BadSequence('Error: need MAIL command')
        address = self.__getaddr('TO:', arg) if arg else None
        if not address:
            raise errors.BadArguments('RCPT TO:<address>')
        self.__rcpt.append(address)
        self.write_ok()
예제 #6
0
    def command_mail(self, arg):
        """Handles the ``MAIL`` SMTP command.

        - Raises a :class:`~bonzo.errors.BadSequence` when a ``HELO`` command
          wasn't previously received.
        - Raises a :class:`~bonzo.errors.BadArguments` when the ``from`` address
          is not received.
        - Raises a :class:`~bonzo.errors.BadSequence` when a ``MAIL`` command
          already was received.
        """
        if not self.__hostname:
            raise errors.BadSequence('Error: need HELO command')
        address = self.__getaddr('FROM:', arg) if arg else None
        if not address:
            raise errors.BadArguments('MAIL FROM:<address>')
        if self.__mail:
            raise errors.BadSequence('Error: nested MAIL command')
        self.__mail = address
        self.write_ok()