我在写一个脚本来登录到Hotmail。它要求用户输入密码,如果他们获得密码,一切都很好。如果我使用poplib给POP服务器无效的证书,为什么我不能再次尝试使用正确的证书?
但是,如果他们第一次收到密码错误,那么有效的密码在后续尝试中将不起作用。
这是我使用什么用户输入自己的密码:
import poplib
M = poplib.POP3_SSL('pop3.live.com', 995) #Connect to hotmail pop3 server
M.set_debuglevel(2)
success = False;
user = "[email protected]"
while success == False:
try:
password = raw_input("password: ")
M.user(user)
M.pass_(password)
except:
print "Invalid credentials"
else:
print "Successful login"
success = True
这里是与调试级别2的输出:
$ python my_program.py
password: password
*cmd* 'USER [email protected]'
*put* 'USER [email protected]'
*get* '+OK password required\r\n'
*resp* '+OK password required'
*cmd* "PASS password"
*put* "PASS password"
*get* '+OK mailbox has 1 messages\r\n'
*resp* '+OK mailbox has 1 messages'
Successful login
$ python my_program.py
password: 1234
*cmd* 'USER [email protected]'
*put* 'USER [email protected]'
*get* '+OK password required\r\n'
*resp* '+OK password required'
*cmd* 'PASS 1234'
*put* 'PASS 1234'
*get* '-ERR authentication failed\r\n'
*resp* '-ERR authentication failed'
Invalid credentials
password: password
*cmd* 'USER [email protected]'
*put* 'USER [email protected]'
*get* '+OK password required\r\n'
*resp* '+OK password required'
*cmd* "PASS password"
*put* "PASS password"
Invalid credentials
缺少什么我在这里?我应该注意到我对python很陌生。
2011-08-07
Dean