Ignore malformed recipient addresses and continue parsing email data
GnTeezer opened this issue · 4 comments
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)
I'm using version 6.6.0
That's not a valid recipient address and the email is malformed. Why do you want to process that email?
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.
Fixed in 6.6.1