Enough-Software / enough_mail

IMAP, POP3 and SMTP clients for Dart developers. Contains both low level as well as a high level API.
Mozilla Public License 2.0
105 stars 55 forks source link

IMAP: uid & guid always return null #200

Closed ducnq232 closed 2 years ago

ducnq232 commented 2 years ago

Have a good day, I am using email with imap4. When i fetch my inbox, all of mail always return with null uid. When I try to get email with other android's lib, I can still get the email's uid. How can i get uid of message with enough mail? Is it a bug? Thank you.

robert-virkus commented 2 years ago

How do you fetch mails?

When you are using the low level ImapClient, it's in your power and responsibility to use the correct query to get the UIDs. You will need to set GUIDs manually, compare the documentation.

The high level MailClient retrieves the UIDs and sets the GUIDs automatically for you. In case it does not, it is either a bug or your mail service does not support UIDs.

Note that GUIDs are client generated only.

ducnq232 commented 2 years ago

When i called method fetchRecentMessages with criteria = 'BODY[]', it does not return uid. I changed criteria = 'UID', it returns uid without body. Because i want both of body and uid, so i call with criteria = 'UID BODY[]' or 'UID BODY.PEEK[]', it throws exception 'POP failed with null'. This is console log: flutter: S: * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. flutter: S: * 3 EXISTS flutter: S: * 0 RECENT flutter: S: * OK [UIDVALIDITY 1655354778] UIDs valid flutter: S: * OK [UIDNEXT 4] Predicted next UID flutter: S: * OK [HIGHESTMODSEQ 9] Highest flutter: S: a2 OK [READ-WRITE] Select completed (0.001 + 0.000 secs). flutter: C: a3 FETCH 1:3 UID BODY.PEEK[] flutter: S: a3 BAD Error in IMAP command FETCH: Invalid arguments (0.001 + 0.000 secs). flutter: POP failed with null flutter: C: a4 LOGOUT flutter: S: * BYE Logging out

robert-virkus commented 2 years ago

You forgot the parentheses around your fetch query.

I recommend using the high level API unless you are fluent in IMAP.

BTW, the "POP failed" message comes from your code. I was puzzled about that at first.

ducnq232 commented 2 years ago

You forgot the parentheses around your fetch query.

I recommend using the high level API unless you are fluent in IMAP.

BTW, the "POP failed" message comes from your code. I was puzzled about that at first.

I see. It returns body with uid when i add parentheses. Thank you for your support!