Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: make Content-Transfer encoder detection more lenient, supporting more values from the wild #456

Closed
bennettlevaton opened this issue Mar 30, 2023 · 2 comments

Comments

@bennettlevaton
Copy link

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?

@bbottema
Copy link
Owner

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.

@bbottema bbottema added this to the 8.0.1 milestone Mar 30, 2023
@bbottema bbottema changed the title Unknown content transfer encoder: QUOTED-PRINTABLE Enhancement: make Content-Transfer encoder detection more lenient, supporting more values from the wild Mar 30, 2023
@bbottema
Copy link
Owner

I released a fix in 8.0.1, you should be able to parse the email correctly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants