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

Ignore malformed recipient addresses and continue parsing email data #321

Closed
GnTeezer opened this issue Jun 11, 2021 · 4 comments
Closed

Comments

@GnTeezer
Copy link

I can't share the original email but the exception was caused because one of the addresses in the To field was this: (null)<>

Index 0 out of bounds for length 0: java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
	at org.simplejavamail.internal.util.MiscUtil.interpretRecipient(MiscUtil.java:181)
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withRecipient(EmailPopulatingBuilderImpl.java:1501)
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withAddresses(EmailPopulatingBuilderImpl.java:1455)
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withAddressesWithDefaultName(EmailPopulatingBuilderImpl.java:1435)
	at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.cc(EmailPopulatingBuilderImpl.java:1115)
	at org.simplejavamail.converter.EmailConverter.buildEmailFromMimeMessage(EmailConverter.java:633)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmailBuilder(EmailConverter.java:120)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmail(EmailConverter.java:99)
	at org.simplejavamail.converter.EmailConverter.mimeMessageToEmail(EmailConverter.java:91)
@GnTeezer
Copy link
Author

I'm using version 6.6.0

@bbottema
Copy link
Owner

That's not a valid recipient address and the email is malformed. Why do you want to process that email?

@GnTeezer
Copy link
Author

I want to process it because I'm replacing a manual system with an automated one and these emails can be opened in any desktop/web client that I've tried so far (they just seem to ignore the malformed address).

I'm certainly no expert but most mail seems to be malformed at some level - we're already setting a lot of the mail.mime.* properties so we can process things that probably aren't technically valid.

I was only reporting this because when I looked at the code for MiscUtil.interpretRecipient I could see that it was handling the AddressException by falling back to a default behaviour so that a Recipient was returned - I thought that might have been the intention for any address that it couldn't parse not just when an AddressException was thrown.

@bbottema bbottema added this to the 6.6.1 milestone Jun 12, 2021
@bbottema bbottema changed the title ArrayIndexOutOfBoundsException in org.simplejavamail.internal.util.MiscUtil.interpretRecipient Ignore malformed recipient addresses and continue parsing email data Jun 12, 2021
@bbottema
Copy link
Owner

Fixed in 6.6.1

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