simple-java-mail icon indicating copy to clipboard operation
simple-java-mail copied to clipboard

Embedded Attachment CID is set as Name ('Causes Security Rejections When Content-ID set as [email protected])

Open furkan-atak opened this issue 4 months ago • 0 comments

When I convert a byte source to MimeMessage:

byte[] emailContent = //some proper email content. InputStream emailInputStream = new ByteArrayInputStream(emailContent); MimeMessage mimeMessage = EmailConverter.emlToMimeMessage(emailInputStream);

My embedded image part looks like this (as it should be): ------=_Part_0_1439752497.1755587044144 Content-Type: image/png; name=ss.png Content-Transfer-Encoding: base64 Content-Disposition: inline; filename=ss.png Content-ID: [email protected]

Then for my needs I convert it to EmailPopulating > Email > String eml like this:

EmailPopulatingBuilder emailPopulatingBuilder = EmailConverter.mimeMessageToEmailBuilder(mimeMessage); String eml = EmailConverter.emailToEML(emailPopulatingBuilder.buildEmail());

In the EML embedded image content looks like this: ------=_Part_5_1773492599.1755587598920 Content-Type: image/png; filename="[email protected]"; name="[email protected]" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="[email protected]" Content-ID: [email protected]

As you see filename and name parts became the CID itself. So when I try to send this mail it's rejecting by providers because image names cannot end with .com

I think, embedded file name should be stayed always like at first, conversion make it lost.

furkan-atak avatar Aug 19 '25 07:08 furkan-atak