Open jf-kisters opened 4 months ago
Does anybody have an idea on how I can proceed here?
@jf-kisters The only other long shot I can think of is jakarta.mail.internet system (not session) properties.
Do you have the exact Exchange version?
Most likely we would have to patch the IMAP with a new property to do what you want.
I'm sorry I didn't see your message earlier, somehow github shows replies to me only after a couple of days?? Regardless, we don't get any reply from our customer anymore and our support ticket with them has been closed after a couple of weeks of trying to raise them -.- (I actually don't know if they just live with that issue now, it definitely wasn't resolved last I checked...) All I can say is that the BODYSTRUCTURE response of the exchange server is broken since Exchange apparently doesn't understand RFC-2251 properly. In our special case we don't really need the distinction of mailservers anyways; if we would have the possibility to always enforce the local (POP3-Style) handling of E-Mails - regardless of mailserver - it would actually serve our usecase.
Is there any chance here to get a possibility to enable POP3-style local parsing for IMAP?
@jf-kisters what is the exact version of Exchange? We will need this to test and verify the fix.
It will be sometime before I can look at this feature.
Also I'll repost again what I want you to try but explained better:
https://stackoverflow.com/questions/14566422/issue-retrieving-attachment-filename-with-javamail
Note: This is a "repost" of https://github.com/jakartaee/mail-api/issues/733, which I created in the wrong project.
Describe the bug We are trying to access a local-run Microsoft Exchange Server via IMAP. This leads us to retrieving attachments of incoming mails with cut-off filenames. After enabling Debug logging we can see that jakarta mail is not downloading the entire MIME structure of the e-mail but is utilizing IMAP to fetch information about attachments via the BODYSTRUCTURE call. Apparently, Exchange is too stupid to support RFC-2251 properly, which allows long fields to be split into multiple lines, and favors to return a cut-off filename instead. This was proven with the logs, the response to the BODYSTRUCTURE call contained the clipped filename (parts of the extension were missing due to them being in the next line inside the MIME structure)
Since we know that jakarta mail also supports POP3, and POP3 expects the mail to be parsed locally, is there a way to alter its behavior on IMAP connections to be the same? Our usecase mandates that we are downloading the entire mail including attachments anyways, so parsing MIME locally would both circumvent the idiocy of Exchange and not come at mentionable cost to us transmission-wise.
To Reproduce Steps to reproduce the behavior: Not really reproducible, this occurs on a customer system with some local Microsoft Exchange server of which operations are even outsourced to a sub-contractor...
Expected behavior Jakarta Mail should ignore the fact that we are talking IMAP and request a download of the entire MIME structure for local parsing as it would do for POP3, instead of using IMAP commands for server-side parsing.
Screenshots N/A
Desktop (please complete the following information): Unknown/Irrelevant
Mail server:
Additional context N/A
In the other ticket, we already spoke about
mail.imaps.partialfetch=false
, however:I tried it, but it seems it only determines if it downloads the entire bodypart in one go or in chunks. However, even with partialfetch = false, it is still handling the message parts individually by calling BODYSTRUCTURE and FETCH for individual parts of the message, as opposed to fetching the entire MIME in one go. For comparison, when I manually connect to the Mailserver I do a
which fetches the entire Mime structure, including headers, body and all attachments. Jakartamail instead performs the following
It is this way of essentially handing the MIME Parsing to the server (by asking for body parts via the protocol) that allows Exchange to botch the BODYSTRUCTURE response and cut of the file name because Exchange doesn't handle RFC-2251 properly