Kaj Hejer opened SPR-8929 and commented

It would be nice if org.springframework.mail.javamail.JavaMailSenderImpl had a setContentTransferEncoding method for overriding the default value for "Content-Transfer-Encoding" generated my JavaMail.

They use the following algorithm:

If the primary type of this datasource is "text" and if all the bytes in its input stream are US-ASCII, then the encoding is "7bit". If more than half of the bytes are non-US-ASCII, then the encoding is "base64". If less than half of the bytes are non-US-ASCII, then the encoding is "quoted-printable".

from http://docs.oracle.com/javaee/6/api/javax/mail/internet/MimeUtility.html#getEncoding(javax.activation.DataSource)

See also

http://www.oracle.com/technetwork/java/faq-135477.html#howencode

and

http://forum.springsource.org/showthread.php?61174-MimeMessageHelper-and-base64-as-Content-Transfer-Encoding


Affects: 3.1 GA

Reference URL: http://forum.springsource.org/showthread.php?61174-MimeMessageHelper-and-base64-as-Content-Transfer-Encoding

Comment From: spring-projects-issues

Bulk closing outdated, unresolved issues. Please, reopen if still relevant.

Comment From: kajh

Can you please repopen this issue. I think it still is relevant. Thanks!

Comment From: kajh

Thank you for reopening!

Comment From: snicoll

@kajh I am not sure what you would expect JavaMailSenderImpl to do. It doesn't sound sane to me to introduce a single value for the header since it depends on the actual content of the body and there is no link between the two.

Reading this SO thread and the source code of MimeMessage. It looks like setting the header after the content was set would work. You can achieve all of that without a change in the core framework.

Can you please give that a try and report if you think that a change in Spring Framework is still required?

Comment From: kajh

Thanks for looking into this! I can take a closer look at this next time we will do some emailingstuff with Spring. That could be a some time later this year.

For my part feel free to close this issue, and I can comment on it in case we don´t manage to do what we want :)

Comment From: snicoll

Thanks for the follow-up @kajh. I believe this should be possible with MimeMessage but if that turns out to be the case and we need to change something on our side, please comment and we'll reopen.