Hi Manuel On Tue, Feb 1, 2022 at 12:19 PM Shenavai, Manuel <manuel.shena...@sap.com.invalid> wrote: > we found the following problem when using the camel mail component (scenario > is like polling mails and forwarding them to another mailbox): > If a mail is containing multiple attachments with the same name, only one of > the attachments will be forwarded. > > We would expect that both attachments get forwarded. Can this be considered a > bug?
I've read, what I think is, the relevant RFC section[1] and the `filename` is not guaranteed to be unique. I think the issue is how the attachment key is generated in the `MimeMultipartDataFormat::getAttachmentKey`[2] method. I think we could guarantee uniqueness there by either keeping track of already used keys and adding an additional unique suffix to the key, which is more backward compatible, or, simpler, by generating a unique (e.g. UUID) key for each attachment regardless of the name . In any case, I think we should add an additional header to Attachment added here[3] with the original file name. You're more than welcome to create an issue[4] and have a stab at proposing a fix via a pull request. zoran [1] https://datatracker.ietf.org/doc/html/rfc2183#section-2.3 [2] https://github.com/apache/camel/blob/24ab5689f0a82ea5e1ff0b208b5b21a235bc2ac0/components/camel-mail/src/main/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormat.java#L304-L320 [3] https://github.com/apache/camel/blob/24ab5689f0a82ea5e1ff0b208b5b21a235bc2ac0/components/camel-mail/src/main/java/org/apache/camel/dataformat/mime/multipart/MimeMultipartDataFormat.java#L273-L274 [4] https://issues.apache.org/jira/secure/CreateIssue!default.jspa -- Zoran Regvart