recipe-203610.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
def popauth(popHost, user, passwd): 
    """ 
    Log in and log out, only to verify user identity. 
    Raise exception in case of failure. 
    """ 
    import poplib 
    try: 
        pop = poplib.POP3(popHost) 
    except: 
        raise StandardError, "Could not establish connection "+\ 
                             "to %s for password check" % popHost 
    try: 
        # Log in and perform a small sanity check 
        pop.user(user) 
        pop.pass_(passwd) 
        length, size = pop.stat() 
        assert type(length) == type(size) == type(0) 
        pop.quit() 
    except: 
        raise StandardError, "Could not verify identity. \n"+\ 
              "User name %s or password incorrect." % user 
        pop.quit() 
    del pop
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号