Skip to content

Ignore malformed recipient addresses and continue parsing email data #321

Closed

Description

@GnTeezer

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)

Activity

  1. GnTeezer commented on Jun 11, 2021

    @GnTeezer
    Author

    I'm using version 6.6.0

  2. bbottema commented on Jun 12, 2021

    @bbottema
    Owner

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

  3. GnTeezer commented on Jun 12, 2021

    @GnTeezer
    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.

  4. added this to the 6.6.1 milestone on Jun 12, 2021
  5. changed the title [-]ArrayIndexOutOfBoundsException in org.simplejavamail.internal.util.MiscUtil.interpretRecipient[/-] [+]Ignore malformed recipient addresses and continue parsing email data[/+] on Jun 12, 2021
  6. added a commit that references this issue on Jun 12, 2021
  7. bbottema commented on Jun 12, 2021

    @bbottema
    Owner

    Fixed in 6.6.1

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions