bbottema/simple-java-mail

emlToEmail() and mimeMessageToEmail() break on mesages with duplicate names and legacy empty nested messages

atmcq opened this issue · 9 comments

atmcq commented

See examples attached. All 3 email files have 2 attachments, however only outlookMsgToEmail() is picking up both of them, emlToEmail() and mimeMessageToEmail() only pick up one attachment.

We will grab the source and try to debug but if there is any chance you know what this might be please let me know as we have a customer problem with this one.

MimeProblem.zip

/edit bbottema: partial regression bugs for #219, #249, #310. Also solves #332

Actually in the latest working code it even throws an exception on account of missing filenames/datasource names. It seems the filename is missing from the EML data and it simply leaves the name empty. I don't see any name information in the multipart data either, but Thunderbird simply names both "ForwardedMessage" (which doesn't occur in the whole EML raw data).

Must have been sent with a version of Outlook that worked slightly differently when naming these specific attachments (using "thread-topic" property from the attached email).

Fixing that, it again finds only 1 attachment.

I figured out why (in the current code at least): the attachments are both named the same and currently attachments with same name are not allowed. I'll fix that and commit it to the develop branch. But I don't think I can do a release any time soon as I'm in the middle of a bunch of changes for the 7.0.0 release.

Hmm, oddly, I changed it to that for #249 (MimeMessageParser doesn't handle multiple attachments with the same name correctly)

Upon further inspection, it seems like a regression bug, but I don't know why. Why did I change the attachment list from Set<Map.Entry<String, DataSource>> to Map<String, DataSource>? Was it so that attachments are sorted and did I accidently remove support for duplicate file names?

Interestingly, the original solution had a bug as well, which I now fixed.

Ok, fixed in develop. Thanks so much for your test data! Will be released in 7.0.0 some day.

atmcq commented

Thanks for picking this up so quick. Is there any way you could add an option to use an Outlook style approach, e,g. to use Thread-Topic for the attachment name, rather than the Thunderbird style "ForwardedEmail.eml"? We have a few legal industry customers that really don't like the idea of an email that they send in to our app "changing" (in their words), as they are coming from using exclusively Outlook.

That's tricky because the name is set before any nested messages are processed. The code would need to be adjusted so that the name is updated after parsing its associated message and then only if it contained the header thread-topic (if that is indeed the canonical approach to handling Outlook messages). Not saying it can't be done, but I haven't looked into that.

atmcq commented

Is there any possibility of porting this fix into a 6.6.2 release? This is causing us some difficulties with some customers.

if that isn't possible, do you have a rough ETA for 7.0.0? Finally if you don't please let us know so we can look into branching and fixing ourselves for now (I assume https://github.com/bbottema/simple-java-mail/commit/9d8dda88dc529f94c2ffaee42b86482936a70454 and https://github.com/bbottema/simple-java-mail/commit/a20655acd6a9960fc8ec4a6a4167299ba452a54e is what we'd need).

atmcq commented

FYI we have done a quick branch of simple-java-mail-6.6.1.jar for now, and will pick up 7.0.0 when it is released. Thanks for your help on this.

Released in 6.7.0. Cheers!