MimeMessageHelper.addAttachment: configurable encoding of attachment filename #25755
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Affects: \5.2.8.RELEASE
I've encountered the following issue in
org.springframework.mail.javamail.MimeMessageHelper#addAttachment(java.lang.String, javax.activation.DataSource)
:The attachment filename ist added to the MimeBodyPart after calling MimeUtility.encodeText():
mimeBodyPart.setFileName(MimeUtility.encodeText(attachmentFilename));
For longer filenames with non-ASCII characters like german umlauts, this results in a wrong encoding of the filename.
Example: Filename is:
xxxxxxxxxxxxxxxxx xxxxxäxßxxxxx xxxxxxx.pdf
This get's encoded as:
Please note:
This mix of encodings is invalid and it leads to a faulty display of attachment filenames in mailclients, most prominently perhaps Microsoft Outlook.
Please refer to the javamail FAQ for more details: https://javaee.github.io/javamail/FAQ#encodefilename
Would it be possible to remove the call to MimeUtility.encodeText from this method or make it optional?
(edit: fixed typos)
The text was updated successfully, but these errors were encountered: