-
imaplib
This module defines three classes:IMAP4(base class), IMAP4_SSL, IMAP4_stream, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in RFC 2060. It is backward compatible with IMAP4(RFC 1730) servers, but note that the STATUS command is not supported in IMAP4.
上面提到的几个概念,参见《理解概念IMAP4、IMAP4rev1 client protocol》
-
IMAP4_SSL
class imaplib.IMAP4_SSL(host='', port=IMAP4_SSL_PORT, keyfile=None, certfile=None, ssl_context=None)
host默认localhost;
port默认993;
-
常用方法
# IMAP类方法 IMAP4 = IMAP(host, port) # 实例化imap客户端 IMAP4.login(user, password) IMAP.list() # mailbox names list IMAP.select(mailbox= "INBOX", readonly= False) # 返回mailbox中的消息数量,一个tuple IMAP.search(charset, criterion[,...]) # IMAP.fetch(message_set, message_parts) M.search(None, 'FROM', '"name"') M.search(None, '(FROM "name")') M.search('GB2312', 'SUBJECT "中文"'.encode('gb2312'))
-
Reference
理解Python模块imaplib
最新推荐文章于 2023-03-10 09:45:22 发布