def handle_input(self, smtp_command, data=None):
self._command_arguments = data<EOL>self.please_close_connection_after_response(False)<EOL>command = smtp_command.upper()<EOL>try:<EOL><INDENT>try:<EOL><INDENT>self.state.execute(command)<EOL><DEDENT>except StateMachineError:<EOL><INDENT>if command not in self.valid_commands:<EOL><INDENT>self.reply(<NUM_LIT>, '<STR_LIT>' % smtp_command)<EOL><DEDENT>else:<EOL><INDENT>msg = '<STR_LIT>' % smtp_command<EOL>allowed_transitions = self.state.allowed_actions()<EOL>if len(allowed_transitions) > <NUM_LIT:0>:<EOL><INDENT>msg += '<STR_LIT>' % allowed_transitions<EOL>self.reply(<NUM_LIT>, msg)<EOL><DEDENT><DEDENT><DEDENT>except InvalidDataError:<EOL><INDENT>e = sys.exc_info()[<NUM_LIT:1>]<EOL>self.reply(<NUM_LIT>, e.msg())<EOL><DEDENT>except InvalidParametersError:<EOL><INDENT>e = sys.exc_info()[<NUM_LIT:1>]<EOL>if not e.response_sent:<EOL><INDENT>msg = '<STR_LIT>' % smtp_command<EOL>self.reply(<NUM_LIT>, msg)<EOL><DEDENT><DEDENT>except PolicyDenial:<EOL><INDENT>e = sys.exc_info()[<NUM_LIT:1>]<EOL>if not e.response_sent:<EOL><INDENT>self.reply(e.code, e.reply_text)<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>if self.should_close_connection_after_response():<EOL><INDENT>self.close_connection()<EOL><DEDENT>self._command_arguments = None<EOL><DEDENT>
Processes the given SMTP command with the (optional data).
        [PUBLIC API]