Anderson Fagionato Anderson Fagionato - 1 year ago 119
Java Question

Set "mail.strictly_mime.parm_folding" in javamail

I'do use javamail to send mail with long filename attachments. The javamail acts accordingly to more recent RFC, and span the filename in two lines of the mail's header, like this example:

Content-Disposition: ATTACHMENT;
filename*0="=?UTF-8?Q?arquivo_com_nome_grande_e_acentua=C3=A7=C3=A3o.png\"; f";
name*0="=?UTF-8?Q?arquivo_com_nome_grande_e_acentua=C3=A7=C3=A3o.png\"; n";
Content-Transfer-Encoding: BASE64

Mail clients like Outlook don't understand it, so I need to make javamail don;t split the filename in two lines.

Reading the RFC, I found an attribute that says to don't split:

How do I set it in javamail?

Answer Source

The mail.strictly_mime.parm_folding property is for Thunderbird, it's not in the RFC.

According to this Thunderbird article, Outlook doesn't support RFC 2231, which JavaMail is using to encode the filename parameter. You can disable RFC 2231 encoding by setting the JavaMail System property "mail.mime.encodeparameters" to "false". You'll probably want to set the System property "mail.mime.encodefilename" to "true" to use the non-standard filename encoding that Outlook supports.