bbottema / simple-java-mail

Simple API, Complex Emails (Jakarta Mail smtp wrapper)
http://www.simplejavamail.org
Apache License 2.0
1.22k stars 266 forks source link

Order of attachments is lost when converting a MimeMessage to an Email #497

Closed timestudybuddy closed 6 months ago

timestudybuddy commented 6 months ago

I'm writing a script that monitors an IMAP box, and clones bounce messages, adjusting the recipients so that they reach our customers' corresponding Administrators. I'm using simple-java-mail to convert an IMAPMessage/MimeMessage into an Email, which we can then feed into our existing mail subsystem. I've noticed that the order of attachments gets lost during this conversion. Bounce messages follow a specific standard, and the order of these attachments matters.

I traced it down to org.simplejavamail.converter.internal.mimemessage.ParsedMimeMessageComponents.attachmentList being a SortedSet. This effectively orders the attachments by their name. Is there a reason this isn't simply an ArrayList?

bbottema commented 6 months ago

Hmm, I'm not sure, but the decision was made in the early days of this project, presumably due to testing challenges where the attachments were out of order otherwise. However, I replaced it LinkedHashSet and everything tested fine still. Would that would for you?

timestudybuddy commented 6 months ago

Yes, I believe so.

bbottema commented 6 months ago

Released in 8.7.1, can you please verify?

timestudybuddy commented 6 months ago

I confirmed this is working as expected now! Thanks you so much!

On Mar 20, 2024, at 1:39 PM, Benny Bottema @.***> wrote:

Released in 8.7.1 https://github.com/bbottema/simple-java-mail/releases/tag/8.7.1, can you please verify?

— Reply to this email directly, view it on GitHub https://github.com/bbottema/simple-java-mail/issues/497#issuecomment-2010581712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGTP5CMBUHA74M4SWYZ5YS3YZHXXLAVCNFSM6AAAAABEU5GZWGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJQGU4DCNZRGI. You are receiving this because you authored the thread.