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
评论列表
文章目录