I want to filter emails for the presence of a specific custom header field, e.g. "X-my-header-field: my-header-value"
.
I am using Python's imaplib. I unsuccessfully tried the search method: rv, data = mailbox.search(None, "X-my-header-field", 'my-header-value')
.
Does anybody have an idea or hint how to accomplish this? The idea is to filter the emails before downloading it from the server.
I found the answer with the hint of Vikas reply and reading RFC 9051: