Email client shows encoded attachment name instead of decoded file name

Problem

JIRA 7 and newer uses a version of JavaMail (a framework for email reading/writing) which has changed its default handling of encoded email parameters to conform with RFC 2231.  Here is an example showing the same attachment, sent using JavaMail in JIRA 6.4 and 7.0 respectively:



JavaMail used in JIRA 6.4.x and older

JavaMail used in JIRA 7.0.x and newer

JavaMail used in JIRA 6.4.x and older

JavaMail used in JIRA 7.0.x and newer

Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-ID: <55228d63-8105-49eb-a841-57e812d6a25c> Content-Disposition: attachment; filename="=?UTF-8?B?4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ?= =?UTF-8?B?4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ?= =?UTF-8?B?4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQLnR4dA==?="
Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-ID: <c8890c7d-e24a-407b-a94a-fa1127eb5cb9> Content-Disposition: attachment; filename*0="=?UTF-8?B?4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ?= =?UTF-8?B?4pqQ4"; filename*1="pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ?= =?UTF-8?B?4pqQ4pqQ4pqQ4pqQ"; filename*2="4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQ4pqQLnR4dA==?="



Some email clients (including Gmail and Outlook) unfortunately do not conform to RFC 2231.  This means that when JEMH sends attachments in emails that have particularly long names including non-ASCII characters, they are not shown and instead the encoded string is displayed instead.

Solution

This problem can be worked around by setting the below Java property on JIRA startup in order to disable JavaMail's incompatible (but technically correct) encoding of parameters.

mail.mime.encodeparameters=false



Related articles