0

An application is developed on spring boot 1.5.15.RELEASE. Used java-mail-api 1.5.6.

Task: send a letter on gmail with an attachment with cyrillic name

Enviroments: dev: Windows 10 Pro, Payara Server 5.183, java 1.8.0_181 server: Ubuntu 16.04.4, Payara Server 5.183, java 1.8.0_171

Send message code:

MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage, true);
...
messageHelper.addAttachment("тестовый_файл.pdf", templateProcessorService.processTemplate("template.docx", request, "pdf"));

Problem: In a letter sent from the dev environment, the name of the attachment is displayed correctly. In a letter sent from the server environment, the name of the attachment is displayed as

=_UTF-8_B_0J7RgtC60YDRi9GC0LjQtV_RgdGH0LXRgtCwX9C00LXQv9C Ln___ ___filename_1=__BkZg==_=

Please, tell me, what could be the reason and how to fix this problem.

Manoj Choudhari
  • 5,277
  • 2
  • 26
  • 37

1 Answers1

0

try this:

messageHelper.addAttachment(MimeUtility.encodeText("тестовый_файл.pdf", "CP1251", "B"), templateProcessorService.processTemplate("template.docx", request, "pdf")); 

it's help for me

or this https://stackoverflow.com/a/49596504/8425969

Виктор
  • 221
  • 3
  • 5