using org.apache.commons.validator.routines.EmailValidator (1.7) for e-mail validation in Java.
In GMAIL a user is allowed to use myname+anything@gmail.com
and it will go to myname@gmail.com
. However, the EmailValidator
does not allow the +
character. I also tried replacing the +
with %2b
before validation but it also fails.
Any suggestions? Can I add an extra allowed character to my EmailValidator instance? Couldn't find this but guess I would need something like that.
Ps. I don't really want to go to custom regex for various reasons.
The Apache Commons EmailValidator does work with a plus sign.
import org.apache.commons.validator.routines.EmailValidator;
public class MapperMain {
public static void main(String[] args) {
String email = "john+Williams@ennui.co.za";
EmailValidator emailValidator = EmailValidator.getInstance();
System.out.println(emailValidator.isValid(email));
}
}
Outputs:
true