Javamail problem with ñ characters in mail addresses

后端 未结 6 668
花落未央
花落未央 2021-01-19 01:16

I\'m having problems with parse method when usising ñ character:

essage.setRecipients(Message.RecipientType.TO, internetAddress.parse(\"somedir.         


        
6条回答
  •  旧时难觅i
    2021-01-19 01:33

    Verify that your ñ is actually an n-tilde. The following works perfectly for me

    InternetAddress[] list = InternetAddress.parse("fred.joñes@example.com", false);
    for (InternetAddress a : list) {
        System.out.println("[" + a + "]");
    }
    

    It also works when replacing the ñ with a unicode escape (in the source .java file)

    InternetAddress[] list = InternetAddress.parse("fred.jo\u00F1es@example.com", false);
    

    You could try replacing it like this just as a test.

    Edit: BTW I had also used parse("...") with the address and no second parameter, and passed true for strict, both of which also worked.

提交回复
热议问题