imaplib — IMAP4 协议客户端

源代码: Lib/imaplib.py


此模块定义 3 个类, IMAP4 , IMAP4_SSL and IMAP4_stream ,封装到 IMAP4 服务器的连接和实现 IMAP4rev1 客户端协议的大子集作为定义在 RFC 2060 。它向后兼容 IMAP4 ( RFC 1730 ) 服务器,但注意 STATUS 命令在 IMAP4 中不支持。

可用性 :非 WASI。

This module does not work or is not available on WebAssembly. See WebAssembly 平台 了解更多信息。

3 个类的提供是通过 imaplib 模块, IMAP4 是基类:

class imaplib. IMAP4 ( host = '' , port = IMAP4_PORT , timeout = None )

此类实现实际 IMAP4 协议。创建连接并确定协议版本 (IMAP4 或 IMAP4rev1) 当初始化实例时。若 host 未指定, '' (本地主机) 的使用。若 port 被省略,标准 IMAP4 端口 (143) 被使用。可选 timeout parameter specifies a timeout in seconds for the connection attempt. If timeout is not given or is None , the global default socket timeout is used.

The IMAP4 类支持 with 语句。当像这样使用时,IMAP4 LOGOUT 命令被自动发出当 with 语句退出。如:

>>> from imaplib import IMAP4
>>> with IMAP4("domain.org") as M:
...     M.noop()
...
('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])