mscdex / node-imap

An IMAP client module for node.js.
MIT License
2.14k stars 379 forks source link

imap search OR conditions on the SUBJECT content - Error: unsupported search query #892

Closed waterdrop01 closed 1 year ago

waterdrop01 commented 1 year ago

Hello,

I currently use this criteria (working):

imap.seq.search([
    'UNSEEN',
    ['HEADER', 'SUBJECT', 'keyword1'],
  ])

And I'd like to search for UNSEEN emails that have either keyword1 OR keyword2 in the subject. Tried the below syntax, but it throws "Error: unsupported search query":

imap.seq.search([
    'UNSEEN',
    [
      'OR',
      ['HEADER', 'SUBJECT', 'keyword1'],
      ['HEADER', 'SUBJECT', 'keyword2'],
    ],
  ])

as well as this:

imap.seq.search([
    ['OR', 'UNSEEN', ['HEADER', 'SUBJECT', 'keyword1']],
    ['OR', 'UNSEEN', ['HEADER', 'SUBJECT', 'keyword2']],
  ])

and even this ^^ :

imap.seq.search([
    [
      'OR',
      ['OR', 'UNSEEN', ['HEADER', 'SUBJECT', 'keyword1']],
      ['OR', 'UNSEEN', ['HEADER', 'SUBJECT', 'keyword2']],
    ],
  ])

Any help would be much appreciated!

Thanks

mscdex commented 1 year ago

Sounds like an IMAP server problem.

waterdrop01 commented 1 year ago

Ok, I'll investigate on the server side then. Thanks for the confirmation!