When I use this script to login the 163 mail server,there is something wrong! My python env is python 2.7.8 Please help me!
import imaplibdef open_connect(verbose=False):host = 'imap.163.com'port = 993if verbose:print 'Connecting to',hostconnection = imaplib.IMAP4_SSL(host)username = '[email protected]'passwd = 'aaannnmmm'if verbose:print 'Logging in as',usernametry:connection.login(username,passwd)except Exception as err:print 'ERROR:', errreturn connectionc = open_connect()try:tye,data = c.select('INBOX')print tye,datanum_msgs=int(data[0])print 'There are %d messages in INBOX' % num_msgs
finally:c.close()c.logout()
=====
NO ['SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi']
Traceback (most recent call last):File "imap_select.py", line 26, in <module>c.close()File "/usr/lib/python2.7/imaplib.py", line 382, in closetyp, dat = self._simple_command('CLOSE')File "/usr/lib/python2.7/imaplib.py", line 1070, in _simple_commandreturn self._command_complete(name, self._command(name, *args))File "/usr/lib/python2.7/imaplib.py", line 825, in _command', '.join(Commands[name])))
imaplib.error: command CLOSE illegal in state AUTH, only allowed in states SELECTED
===== And then the 163 mail server send me a mail,about this:
该行为存在以下安全隐患:
1) 邮件客户端未经有效识别,不能有效保证帐户安全性,存在帐号密码泄漏的风险;
2) 数据传输安全性低,存在数据泄漏风险。
In English is :
1) mail client not a security client
2) data streaming is notsecruity
Thanks a lot. This is the debug info . I think that I must a have a TLS1.2 version conection.
05:59.52 > ENFK1 LOGIN "[email protected]" "aaannnmmm"05:59.54 < ENFK1 OK LOGIN completed05:59.54 matched r'(?P<tag>ENFK\d+) (?P<type>[A-Z]+) (?P<data>.*)' => ('ENFK1', 'OK', 'LOGIN completed')05:59.54 > ENFK2 SELECT INBOX05:59.54 < ENFK2 NO SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi05:59.54 matched r'(?P<tag>ENFK\d+) (?P<type>[A-Z]+) (?P<data>.*)' => ('ENFK2', 'NO', 'SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi')05:59.54 NO response: SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi
NO ['SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi']
Traceback (most recent call last):File "imapselect.py", line 31, in <module>c.close()File "/usr/lib64/python2.6/imaplib.py", line 375, in closetyp, dat = self._simple_command('CLOSE')File "/usr/lib64/python2.6/imaplib.py", line 1060, in _simple_commandreturn self._command_complete(name, self._command(name, *args))File "/usr/lib64/python2.6/imaplib.py", line 818, in _command', '.join(Commands[name])))
imaplib.error: command CLOSE illegal in state AUTH, only allowed in states SELECTED