def handle_mail(state: State, arguments: str) -> Reply: if arguments[:5].upper() != "FROM:": return handle_wrong_arguments() try: path, rest = parse_reverse_path(arguments[5:]) except ValueError as exc: return handle_wrong_arguments(str(exc)) if not is_valid_smtp_arguments(rest): return handle_wrong_arguments() if not state.greeted: return handle_no_greeting() if not state.mail_allowed: return handle_bad_command_sequence() state.clear() state.reverse_path = path return SMTPStatus.OK, "Sender OK"
def handle_rset(state: State, arguments: str) -> Reply: if arguments: return handle_unexpected_arguments() state.clear() return SMTPStatus.OK, "OK"