bbottema/simple-java-mail

Add support for non-English attachment names

ensean opened this issue · 5 comments

I meet a problem that while using this tool to send attachments with non-English name, it seems that the receiver's mail server can not decode the attachment name correctly. Detailed info is as follows:

Please note that the base64 data of the attachments are omit

  • eml generated by this tool
------=_Part_0_1135323183.1481683823991
Content-Type: application/octet-stream; filename=ODS
簸?.docx; name=ODS
簸?
Content-Transfer-Encoding: base64
Content-Disposition: attachment; size=0; 
	filename*=utf-8''ODS%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%BB%B4%E6%8A%A4%E8%AF%B4%E6%98%8E.docx
Content-ID: <ODS
簸?>

------=_Part_0_1135323183.1481683823991
Content-Type: application/octet-stream; filename=CP?燒?.xlsx; name=CP?燒?
Content-Transfer-Encoding: base64
Content-Disposition: attachment; size=0; 
	filename*=utf-8''%E6%9D%83%E9%99%90%E6%8E%A7%E5%88%B6%E5%8A%9F%E8%83%BD%E8%AF%B4%E6%98%8E.xlsx
Content-ID: <CP?燒?>

------=_Part_0_1135323183.1481683823991
Content-Type: application/octet-stream; filename=�披��(?.txt; name=�披��(?
Content-Transfer-Encoding: base64
Content-Disposition: attachment; size=0; 
	filename*=utf-8''%E3%80%90%E5%BF%85%E8%AF%BB%E3%80%91%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E.txt
Content-ID: <�披��(?>
  • eml generated by the sender mail server(send mail to server by the web client of the sender's server, the receiver's server can decode the attachment correctly)
------=_Part_68043_345475145.1481684426317
Content-Type: application/octet-stream;
 name="=?GBK?Q?ODS=B7=FE=CE=F1=C6=F7=CE=AC=BB=A4=CB=B5=C3=F7.docx?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="=?GBK?Q?ODS=B7=FE=CE=F1=C6=F7=CE=AC=BB=A4=CB=B5=C3=F7.docx?="

------=_Part_68043_345475145.1481684426317
Content-Type: application/octet-stream;
 name="=?GBK?B?yKjP3r/Y1sa5psTcy7XD9y54bHN4?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="=?GBK?B?yKjP3r/Y1sa5psTcy7XD9y54bHN4?="

------=_Part_68043_345475145.1481684426317
Content-Type: application/octet-stream;
 name="=?GBK?B?ob6x2LbBob/KudPDy7XD9y50eHQ=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="=?GBK?B?ob6x2LbBob/KudPDy7XD9y50eHQ=?="

So, is it possible the set the encoding method for the attachment name ?

I find a work around as follows...

mail.addAttachment(MimeUtility.encodeText(attachmentName), new FileDataSource(attachmentPath))

I've seen your issue and I still intend to fix it on my side as well...

Will be solved in v4.1.3

Released in 4.1.3.

Great!