jakartaee / jakartaee/mail-api

javamail cannot issue UID FETCH and doesn't fully support workaround

Open
#197 6 comments 0 reactions 1 assignee Claimed by @bshannon View on GitHub
Component: imap minor Priority: P5
Dominant language
Java
Stars
285
Forks
109
Avg merge
15h 19m
Merged PRs (30d)
1

Description

Javamail doesn't support UID FETCH at present. You *can* get a Message by UID and then do a FETCH by sequence number, but that's an extra round trip.

The semi-obvious workaround for this is to use Folder.doCommand() and issue a UID FETCH of your own:

folder.doCommand(p -> {
p.simpleCommand("UID FETCH", args);
return null;
});

And this works... mostly. If there's a message with that UID in the folder, the IMAP server will return an untagged FETCH response which will be caught by Protocol.simpleCommand() and handed off to Protocol.notifyResponseHandlers() and then to IMAPFolder.handleResponse(). It finally lands in IMAPFolder.processFetchResponse(), which handles UID, MODSEQ, FLAGS, and extensions. Everything else is dropped. (IMAPFolder.handleResponse also sends a MessageChangedEvent, which is not optimal, but it's not an issue for me as I don't have any listeners active on the Folder.)

Would it be possible to either

a) support UID FETCH directly, or
b) have IMAPFolder.processFetchResponse() handle at least a larger subset of the other fetch items, like IMAPMessage.handleFetchItem() does?
#### Affected Versions
1.5.5
#### Environment
PC
Mac OS

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.