IMAP search not working for HEADER searches

Discussion forum for Enterprise Edition.
Post Reply
bigreddastud
Posts: 43
Joined: Tue Apr 19, 2005 7:30 pm

IMAP search not working for HEADER searches

Post by bigreddastud » Sun Feb 21, 2021 6:27 pm

RFC3501 specifies the ability to submit IMAP searches on message headers

https://tools.ietf.org/html/rfc3501#page-49
HEADER <field-name> <string>
Messages that have a header with the specified field-name (as
defined in [RFC-2822]) and that contains the specified string
in the text of the header (what comes after the colon). If the
string to search is zero-length, this matches all messages that
have a header line with the specified field-name regardless of
the contents.
However, when I try searching with a query that includes a header term, ME seems to simply ignore it. Take this query for example, I get a result set that has messages with and without the "List-Unsubscribe" header defined, however, I should only get messages from "somedomain" where they provide the "List-Unsubscribe" header.

Code: Select all

'HEADER "List-Unsubscribe" "somedomain.com" FROM "somedomain.com"'
I'm working with ME v10.32 (current latest version) and also had the same behavior on a recent version (perhaps v10.3?).

Is this a bug, or known issue?

MailEnable-Ian
Site Admin
Posts: 9335
Joined: Mon Mar 22, 2004 4:44 am
Location: Melbourne, Victoria, Australia

Re: IMAP search not working for HEADER searches

Post by MailEnable-Ian » Mon Feb 22, 2021 4:14 am

Hi,

Developers have reviewed this in more detail and have found an issue. It will be addressed in the next minor release.
Regards,

Ian Margarone
MailEnable Support

MailEnable-Ian
Site Admin
Posts: 9335
Joined: Mon Mar 22, 2004 4:44 am
Location: Melbourne, Victoria, Australia

Re: IMAP search not working for HEADER searches

Post by MailEnable-Ian » Mon Feb 22, 2021 5:30 am

Hi,

Beta page below contains revised kits with the fix you require for the IMAP header search:

https://www.mailenable.com/beta/
Regards,

Ian Margarone
MailEnable Support

bigreddastud
Posts: 43
Joined: Tue Apr 19, 2005 7:30 pm

Re: IMAP search not working for HEADER searches

Post by bigreddastud » Tue Feb 23, 2021 12:18 am

@MailEnable-Ian --> Thanks!

I installed the beta you linked and it's working better, but it's not quite fully fixed/compliant with the RFC. It's still not working for searches where the header simply exists in the email, without specifying a search term within the header value.
If the string to search is zero-length, this matches all messages that have a header line with the specified field-name regardless of the contents.
Take these two searches. The 1st search *should* find 1 message as it's found when I specify a search term for within the header value (2nd search), so we know the header exists, and per the RFC should the 1st search should result in a match for any messages that have that header.

Code: Select all

Processing search term 'FROM "user@mail.domain.com" HEADER "List-Unsubscribe" BEFORE 01-Feb-2021'
Your search found 0 messages
[]

Code: Select all

Processing search term 'FROM "user@mail.domain.com" HEADER "List-Unsubscribe" "domain.com" BEFORE 01-Feb-2021'
Your search found 1 messages
[39004]
Working with messages[39004]
ID #39004: "[SPAM**V2] Last chance to use your Super Secret VIP offer." received 2021-01-27 09:47:57
I also tried hard-coding an empty string into the search, but that gave the same results as the first search string (where no term was specified):

Code: Select all

Processing search term 'FROM "user@mail.domain.com" HEADER "List-Unsubscribe" "" BEFORE 01-Feb-2021'
Your search found 0 messages
[]

MailEnable-Ian
Site Admin
Posts: 9335
Joined: Mon Mar 22, 2004 4:44 am
Location: Melbourne, Victoria, Australia

Re: IMAP search not working for HEADER searches

Post by MailEnable-Ian » Tue Feb 23, 2021 6:04 am

Hi,

Ok there is another revised version on the beta page. The developers have fixed it where it was not matching the string. However it cannot be empty (I.e: "") you need to specify the string.
Regards,

Ian Margarone
MailEnable Support

bigreddastud
Posts: 43
Joined: Tue Apr 19, 2005 7:30 pm

Re: IMAP search not working for HEADER searches

Post by bigreddastud » Tue Feb 23, 2021 11:37 pm

Perfect. It seems to be working now, as shown below:

Code: Select all

Processing search term 'FROM "user@mail.domain.com" HEADER "List-Unsubscribe" "" BEFORE 01-Feb-2021'
Your search found 1 messages
[39004]
Working with messages[39004]
ID #39004: "[SPAM**V2] Last chance to use your Super Secret VIP offer." received 2021-01-27 09:47:57
For clarity, you'll have to supply the empty search string in order for the search to match any messages where the header exists. (i.e. exactly as shown below), which is also how I interpret the RFC's definition.

Code: Select all

HEADER "Your-Header-here" ""
Thanks!

Post Reply