postalsys / imapflow

IMAP Client library for EmailEngine Email API (https://emailengine.app)
https://imapflow.com
Other
367 stars 64 forks source link

Fetching Emails with UID Seems to Use Sequence IDs Instead #220

Closed josepmy closed 3 weeks ago

josepmy commented 1 month ago

I found an issue where older emails on the email server don't have sequence IDs, while newer emails do. When using the fetch() method, I explicitly set uid: true to fetch emails by UID. However, it seems like the library still relies on sequence IDs to retrieve the emails, even though I specified using UIDs.

Here's the issue: older emails have valid UIDs but no sequence IDs. When I try to fetch them, the library appears to search by sequence instead of UID, causing it to fail to find the emails despite having their valid UIDs.

And show the error: Error: Error: Command failed at ImapFlow.reader (/Users/xxx/my-email-dashboard/node_modules/imapflow/lib/imap-flow.js:571:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { response: { tag: 'A', command: 'BAD', attributes: [ [Object] ] }, responseStatus: 'BAD', responseText: 'Error in IMAP command FETCH: Invalid messageset (0.001 + 0.000 secs).'

Am I doing something wrong? I've followed the documentation, but the fetch behavior doesn't seem to align with the expected uid: true functionality. Any insights would be appreciated.

andris9 commented 3 weeks ago

Not sure what exactly you are doing wrong, but ImapFlow can handle UID fetching correctly. Make sure your are not referencing UID values that do not exist on the server.

josepmy commented 3 weeks ago

@andris9 The problem is that I use a valid UID but is fetching by sequence, and the UID value as a sequence doesn't exist.

enyo commented 2 days ago

@josepmy make sure you set the uid: true config in the options argument (3rd argument) and not in the fetch query argument (2nd argument). So something like this:

await client.fechOne(uid, { source: true }, { uid: true });
// instead of:
await client.fechOne(uid, { source: true, uid: true });