bbottema/simple-java-mail

Immediately resolve InputStreams when building emails, don't reuse

DJAxion opened this issue · 4 comments

Hi, we run into a problem where we have an email signed with a PKCS12 key store. Sending the mail goes as expected, and the mail is signed and sent.
Next, we want to store that email for archiving, but EmailConverter.emailToEML(email) seems to re-use the stream in which the key store is provided, resulting in an IOException.

Are you providing the input stream yourself?

I'm not too happy how input streams are handled, because it provides the problem you describe. However reading the contents in the Email means moving some logic to the builder which also shouldn't be there. Perhaps I should remove support for manual input streams altogether...

No, we are using the EmailBuilder and indeed add the inputstream to signWithSmime (for the key). There is an option to add a file, but the first thing that happens in the EmailPopulatingBuilderImpl is creating an inputstream of that file, so that also isn't a solution/workarround for us.

Fix released in 6.4.0.

The api remains largely the same (expanded with byte[] versions), but any input stream passed into the api is resolved immediately now so it won't cause issues lateron.

It would be of great help if you could confirm whether 6.4.0 works for your use case.

Sorry for the late response, but I can confirm it's working now! Thanks for your support.