-1

To validate email I am using following method i.e. official java email package

public static boolean isValidEmailAddress(String email) {
boolean result = true;
try {
  InternetAddress emailAddr = new InternetAddress(email);
  emailAddr.validate();
} catch (AddressException ex) {
  result = false;
}
return result;
}

But above method also considers true for even "[email protected]", "[email protected]? I will be grateful if someone please help me out in removing above all these while validating email id of a user? I searched in google but could not find any solution. Many thanks in advance

Tom
  • 761
  • 7
  • 22
  • 41

1 Answers1

0

The official Java email package considers things like [email protected] and [email protected] as valid email addresses, since they are according to the RFC. Like the people who commented said, it would be best to figure out what rules you're trying to implement for your validation and go from there.

dacmacho
  • 45
  • 5