Imap_ssl.search one letter name

resp_code, mails = imap_ssl.search(None, '(FROM "a")')

I want to search emails from a specific one letter named user, “a”.
Example:

<a@xxxxx.com>
<a@xxxxxx.com>

Problem is, search results cause all users with an “a” as part of there name to be returned.
Example:

jane@xxxxx.com
aaron@xxxxxx.com

Any way to isolate the search to one letter name?

just use a regular expression to do it
look up the ‘re’ python library

Hello @hbar1st
The ‘re’ is having no effect on my searches, a{1} should result in, no more then 1 character, and that character should be “a”.
Am I understanding it correctly? Is there a syntax issue below?

resp_code, mails = imap_ssl.search(None, '(FROM "a{1}")')

SOURCE

{m} Specifies that exactly m copies of the previous RE should be matched; fewer matches cause the entire RE not to match. For example, a{6} will match exactly six 'a' characters, but not five.

sorry I’m not familiar with the search function you are using. I was just suggesting that you utilize the regular expression library in python to do the string matching

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.