python login 163 servidor de correo

Cuando uso este script para iniciar sesión en el servidor de correo 163, ¡hay algo mal! Mi python env es python 2.7.8 ¡Ayúdenme!

import imaplib

def open_connect(verbose=False):
    host = 'imap.163.com'
    port = 993
    if verbose:print 'Connecting to',host
    connection = imaplib.IMAP4_SSL(host)
    username = '[email protected]'
    passwd = 'aaannnmmm'
    if verbose:print 'Logging in as',username
    try:
        connection.login(username,passwd)
    except Exception as err:
        print 'ERROR:', err

    return connection

c = open_connect()

try:
    tye,data = c.select('INBOX')
    print tye,data
    num_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 close
    typ, dat = self._simple_command('CLOSE')
  File "/usr/lib/python2.7/imaplib.py", line 1070, in _simple_command
    return 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

===== Y luego el servidor de correo 163 me envió un correo, sobre esto:

该行为存在以下安全隐患:
1) 邮件客户端未经有效识别,不能有效保证帐户安全性,存在帐号密码泄漏的风险;
2) 数据传输安全性低,存在数据泄漏风险。

En inglés es:

1) mail client not a security client 
2) data streaming is notsecruity

Muchas gracias. Esta es la información de depuración. Creo que debo tener una conexión de versión TLS1.2.

  05:59.52 > ENFK1 LOGIN "[email protected]" "aaannnmmm"
  05:59.54 < ENFK1 OK LOGIN completed
  05:59.54      matched r'(?P<tag>ENFK\d+) (?P<type>[A-Z]+) (?P<data>.*)' => ('ENFK1', 'OK', 'LOGIN completed')
  05:59.54 > ENFK2 SELECT INBOX
  05:59.54 < ENFK2 NO SELECT The login is not safe! Please update your mail client: http://mail.163.com/dashi
  05: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 close
    typ, dat = self._simple_command('CLOSE')
  File "/usr/lib64/python2.6/imaplib.py", line 1060, in _simple_command
    return 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

Respuestas a la pregunta(3)

Su respuesta a la pregunta