shinji
shinji

Reputation: 61

IMAP search for address is equal not contains

=)

I need get all messages from email inbox with specific address. For that i use command:

self.server.search(None, '(HEADER FROM "[email protected]")')

and it's work but when I try find message form [email protected] I got the same results. And I know with this criteria I searching all messages CONTAINS specific string. But for me [email protected] and [email protected] is diffrents addresses. How can I search for EQUAL not CONTAINS addresses?

import imaplib
self.server = imaplib.IMAP4(self.imap_ssl_host, self.imap_ssl_port)    

Upvotes: 0

Views: 326

Answers (1)

arnt
arnt

Reputation: 9685

You can try searching for <[email protected]> instead of [email protected].

A message from [email protected] usually says From: Firstname Lastname <[email protected]>, which contains the substring <test@, and most IMAP searches are substring searches, including FROM. If this hack is enough for you and whatever server you're using, good for you, otherwise you need to do clientside filtering to remove the false positives.

Upvotes: 1

Related Questions