This discussion is archived
1 Reply Latest reply: Apr 9, 2012 11:18 AM by bshannon RSS

error with underscore in InternetAddress parse with strict = false

849103 Newbie
Currently Being Moderated
Hi all,

I run the following code (using javamail version 1.4.3):
    public static void main(String[] args) throws Throwable  {
        InternetAddress.parse("", false);
And I got the following exception:
Exception in thread "main" javax.mail.internet.AddressException: Domain contains illegal character in string ``''
     at javax.mail.internet.InternetAddress.checkAddress(
     at javax.mail.internet.InternetAddress.parse(
     at javax.mail.internet.InternetAddress.parse(
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.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points