Since I’ve upgraded to framework v7 I’m having trouble with sending emails with attachments that have long filenames. The Content-Disposition header is;
Can you please provide the exact attachment file name you have used?
Also, what is your deployment environment? Maybe there is another version of javax.mail implementation library on the classpath which causes the trouble?
{supplier_reference} AUTO_TEST_GTC Gas MeterGas Service And Met.pdf
In the email headers it’s shown as
=UTF-8Q{supplier=5Freference} AUTO=5FTEST=5FGTC Gas Service And Met.pdf=
With smaller (around 20 character filenames) filenames the problem doesn’t occur. Delving into java mailer I can see the class ParameterList splits the name if more than 60 characters if mail.mime.splitlongparameters is true. I am trying to set that as false in JAVA_OPTS to see if that helps but not successful at the moment (am I setting that in the right place?)
I have been able to replicate on a standard project with the following code to send a test email (I can’t work out how to zip the project otherwise I would attach it all)
EmailAttachment emailAttachment = EmailAttachment.createTextAttachment("test attachment", "utf8", "test4787429379473927894789732895774375893248975893427895789324789578934275897342897589732489758932479857923475984334897598.txt");
EmailInfo emailInfo = new EmailInfo(
"test@example.com", // recipients
"test send", // subject
null, // the "from" address will be taken from the "cuba.email.fromAddress" app property
"This is a test email 2", // template parameters
EmailInfo.TEXT_CONTENT_TYPE,
emailAttachment
);
emailService.sendEmailAsync(emailInfo);
}
Many thanks. If it helps, this used to work in v6.x and in the standalone project in v7 I set the system property “mail.mime.splitlongparameters” to false and the filename comes across as expected when that is set.
The email naming conventions and standards obviously allow for the splitting of names so it is odd that it doesn’t work as expected.