Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IMAP search with a full string

Tags:

imap

I am currently trying to search some email in my Inbox with a string like that "not working anymore" but the problem is that imap will return me the list of email containing the 3 words and not the string "not working anymore".

Any idea how to resolve this? I have no messages containing this string, but the IMAP returns me 2 results because of the problem explained above.

a1 SEARCH BODY "not working anymore" 
* SEARCH 4090 7752
like image 708
Guillaume Rebmann Avatar asked Jul 31 '26 09:07

Guillaume Rebmann


1 Answers

Filter/verify the server's result in your client code.

The longer answer is that IMAP servers used to do what you want, but as users wanted smarter fuzzier faster searching, servers started implementing it. For example, users wanted to find messages like this:

foo foo foo foo foo foo foo not working
anymore foo foo foo foo

The whitespace does not match your search term. Do you think the server should return that message?

The IMAP specification is silentish on the issue. As I read it, if a message contains the exact string, that specification says the message must match the search, but if the message doesn't, then... well, then server and client should act to satisfy the user and bring about world peace. This implies that the search result you get from the server contains all the messages you want, so filtering won't miss any results.

like image 176
arnt Avatar answered Aug 03 '26 06:08

arnt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!