bbottema/simple-java-mail

Bug: Multiple attachments with same name get the same Content-ID, causing them to refer to the same file content

Closed this issue · 4 comments

When I'm trying to send an email where multiple attachments with the same name, the receiver thinks that it is always the same attachment and shows the same content for all attached files.
I have tested this with versions 6.5.2 and 8.3.1.

In my opinion, the problem is the assignment of the BodyPart ID in org.simplejavamail.converter.internal.mimemessage.MimeMessageHelper.getBodyPartFromDatasource(AttachmentResource, String) (line 288) where the Content-ID header of the part is based solely on the filename of the attachment. I suggest to always add a UUID at the end to ensure uniqueness.

Hmm, interesting. I'm not a fan of using UUID, that makes the filenames unwieldy, but a sequence number could work... I'll have a look.

Isn't the filename determined by the filename parameter of the Content-Type header? The Content-ID should not have any influence on the filename.

This should now be fixed in 8.3.2. Can you please verify, if you get a chance?

I can confirm that the problem is resolved now (I checked with version 8.6.2).
Thank you very much, sir.