IMAP4.search()
IMAP4.search() is a Python method in the Imaplib Module category. Searches for messages matching criteria. The syntax is IMAP4.search(charset, *criteria). Returns: (status, data) tuple. A typical example: type, data = imap.search(None, "FROM", "alice@example.com")
type, data = imap.search(None, "UNSEEN") # Unread messages
type, data = imap.search(None, "SINCE", "01-Jun-2026"). A close sibling is imaplib.IMAP4(), which creates an IMAP4 client for reading/managing emails on a server. A close sibling is IMAP4.login(), which logs into the IMAP server with username and password. A close sibling is IMAP4.select(), which selects a mailbox for operation. A close sibling is IMAP4.fetch(), which fetches message data (RFC822 full message, or headers/body parts). More about this category: IMAP4 email client — IMAP4, login, list, select, search, fetch, store. Related Imaplib Module entries: imaplib.IMAP4(), IMAP4.login(), IMAP4.select(), IMAP4.fetch(), IMAP4.store(), IMAP4.list(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.