Anderson Fagionato Anderson Fagionato - 23 days ago 10
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:

------=_Part_0_978693914.1433356404377
Content-Disposition: ATTACHMENT;
filename*0="=?UTF-8?Q?arquivo_com_nome_grande_e_acentua=C3=A7=C3=A3o.png\"; f";
filename*1="ilename*1=\"?="
Content-Type: APPLICATION/OCTET-STREAM;
name*0="=?UTF-8?Q?arquivo_com_nome_grande_e_acentua=C3=A7=C3=A3o.png\"; n";
name*1="ame*1=\"?="
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:
"mail.strictly_mime.parm_folding"

How do I set it in javamail?

Answer

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.