Enhancement: make Content-Transfer encoder detection more lenient, supporting more values from the wild
bennettlevaton opened this issue · 2 comments
I'm trying to decode a mail object which uses Content-Transfer-Encoding: QUOTED-PRINTABLE
and I am not able to get the EmailConverter.mimeMessageToEmailBuilder
to convert the file due to the below exception
Caused by: java.lang.IllegalArgumentException: unknown content transfer encoder: QUOTED-PRINTABLE
at org.simplejavamail.api.email.ContentTransferEncoding.lambda$byEncoder$1(ContentTransferEncoding.java:52)
at java.base/java.util.Optional.orElseThrow(Unknown Source)
at org.simplejavamail.api.email.ContentTransferEncoding.byEncoder(ContentTransferEncoding.java:52)
at org.simplejavamail.converter.EmailConverter.buildEmailFromMimeMessage(EmailConverter.java:667)
at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:136)
at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:122)
at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:114)
at com.forwarding.backend.helpers.EmailParsingHelper.getEmail(EmailParsingHelper.java:179)
I've tried using the builder to define the content encoding
EmailConverter.mimeMessageToEmailBuilder(message)
.withContentTransferEncoding(ContentTransferEncoding.QUOTED_PRINTABLE)
.buildEmail();
But this does not seem to override the above or ignore unknown content sources. Can this be added a feature if not available?
Yes, the .withContentTransferEncoding your are calling is on the resulting email builder, which will take effect when the email from that builder is converted to a MimeMessage (either by manual conversion or by sending it). So that won't help you for reading an email with transfer encoding.
Having said that, even though the literal value "QUOTED-PRINTABLE" is not RFC compliant as far as I know, I think with a minor tweak to the code, Simple Java Mail can support this. I'll have a look.
I released a fix in 8.0.1, you should be able to parse the email correctly now.