Closed 734776328 closed 3 years ago
'UNSEEN'
doesn't have any parameters, so you should instead have something like:
const query = [
'UNSEEN',
['FROM', 'hello@gmail.com'],
]
'UNSEEN'
doesn't have any parameters, so you should instead have something like:const query = [ 'UNSEEN', ['FROM', 'hello@gmail.com'], ]
Hello, thank you, @mscdex , but I used your example and returned all the emails.Have you ever encountered this kind of problem.
The "search" method is invalid and always returns all messages. The completion code is as follows:
I'm not sure what you're meaning by "invalid", the server or imap
shouldn't be rejecting the search criteria. If you mean it's just giving you unexpected results then that's another thing.
My only suggestion would be to try to use ['HEADER', 'From', 'xxxx']
instead of ['FROM', 'xxxx']
. The searches are performed by the server, so ultimately you're at the whims of whatever server implementation and whether or not they deviate from the IMAP spec.
I'm not sure what you're meaning by "invalid", the server or
imap
shouldn't be rejecting the search criteria. If you mean it's just giving you unexpected results then that's another thing.My only suggestion would be to try to use
['HEADER', 'From', 'xxxx']
instead of['FROM', 'xxxx']
. The searches are performed by the server, so ultimately you're at the whims of whatever server implementation and whether or not they deviate from the IMAP spec.
thank @mscdex .
@mscdex hi, @mscdex , Is this "imap" library for Gmail only?
Is this "imap" library for Gmail only?
No
Faced the same problem. I don't know how to solve it
imap.search(
[
'All',
['SINCE', 'July 30, 2022'],
[ 'FROM', 'mail@mail.ru']
],
error:' Unexpected search option: ' + criteria
Error: Unexpected search option: FROM at buildSearchQuery (E:\JS\shellCodeBot\node_modules\node-imap\lib\utils.js:252:19) at Connection._search (E:\JS\shellCodeBot\node_modules\node-imap\lib\Connection.js:519:79) at Connection.search (E:\JS\shellCodeBot\node_modules\node-imap\lib\Connection.js:512:10) at E:\JS\shellCodeBot\get_promo\index.js:34:11 at Connection.<anonymous> (E:\JS\shellCodeBot\node_modules\node-imap\lib\Connection.js:407:9) at Connection._resTagged (E:\JS\shellCodeBot\node_modules\node-imap\lib\Connection.js:1307:24) at Parser.<anonymous> (E:\JS\shellCodeBot\node_modules\node-imap\lib\Connection.js:190:12) at Parser.emit (node:events:390:28) at Parser._resTagged (E:\JS\shellCodeBot\node_modules\node-imap\lib\Parser.js:169:12) at Parser._parse (E:\JS\shellCodeBot\node_modules\node-imap\lib\Parser.js:135:18)
I'm try to use ['HEADER', 'From', 'xxxx'] but it didn't help
@Romax-91 You're using a different module called node-imap
, which is maintained by someone else. This module is simply called imap
on npm.
Why is this "search" invalid?