1 Reply Latest reply on Apr 9, 2012 6:18 PM by Bill Shannon-Oracle

    error with underscore in InternetAddress parse with strict = false

      Hi all,

      I run the following code (using javamail version 1.4.3):
          public static void main(String[] args) throws Throwable  {
              InternetAddress.parse("ab@c_d.pt", false);
      And I got the following exception:
      Exception in thread "main" javax.mail.internet.AddressException: Domain contains illegal character in string ``ab@c_d.pt''
           at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:1211)
           at javax.mail.internet.InternetAddress.parse(InternetAddress.java:1044)
           at javax.mail.internet.InternetAddress.parse(InternetAddress.java:575)
      Now I understand that if I were to use strict = true this would be the correct result, as the given domain is wrong according to RFC1034. But since I used strict = false, shouldn't this work? The docs only refer checking according to RFC1034 when using strict = true, and the address is valid as RFC822, I think...

      Why is this error happening? Is there a way to signal javamail to allow the underscore in the domain part of the address?

      Thanks for your help.