def smtpcli(argv):
    """smtpcli [-h] [-l <logfilename>] [-s <portname>] [host] [port]

Provides an interactive session at a protocol level to an SMTP server. 
    """
    bindto = None
    port = 25
    sourcefile = None
    paged = False
    logname = None
    try:
        optlist, longopts, args = getopt.getopt(argv[1:], "b:hp:s:l:g")
    except getopt.GetoptError:
            print(smtpcli.__doc__)
            return
    for opt, val in optlist:
        if opt == "-b":
            bindto = val
        if opt == "-l":
            logname = val
        elif opt == "-s":
            sourcefile = val
        elif opt == "-g":
            paged = True
        elif opt == "-h":
            print(smtpcli.__doc__)
            return
        elif opt == "-p":
            try:
                port = int(val)
            except __HOLE__:
                print(smtpcli.__doc__)
                return

    theme = UI.DefaultTheme(PROMPT)
    parser = CLI.get_cli(EmailClientCLI, paged=paged, theme=theme)
    if len(args) > 0:
        if len(args) > 1:
            port = int(args[1])
        else:
            port = 25
        host = args[0]
    else:
        host = ""
    if logname:
        parser.commands.logfile(["logfile", logname])
    if host:
        parser.commands.connect(["connect"]+IF(bindto, ["-s", bindto], [])+[host, port])
    else:
        parser.commands._print("Be sure to run 'connect' before anything else.\n")

    if sourcefile:
        try:
            parser.parse(sourcefile)
        except CLI.CommandQuit:
            pass
    else:
        parser.interact()
dataset/ETHPy150Open kdart/pycopia/net/pycopia/smtpCLI.py/smtpcli