Simple RFC compliant EmailValidator for Java.
Suported RFCs
RFC 5321, 5322, 6530, 6531, 6532.
EmailValidator4j is available on JCenter!!!
dependencies {
compile 'egulias:EmailValidator4J:1.0.0'
}
<dependency>
<groupId>egulias</groupId>
<artifactId>EmailValidator4J</artifactId>
<version>1.0.0</version>
<type>jar</type>
<classifier>sources</classifier>
</dependency>
Because you don't want to download internet to validate an email.
import emailvalidator4j.EmailValidator
public class ValidateEmail {
public static void main (String[] args) {
EmailValidator validator = new EmailValidator();
if (validator->isValid(args[0]) {
System.out.println("Valid email");
} else {
System.out.println("Invalid email");
}
}
}
The library comes with an extension point to allow for custom validations.
Validation strategies should implement emailvalidator4j.ValidationStrategy
Will make an email invalid if there's at least one Warning
Will check for the existence of a Mail eXchange record on the host. this makes a dns request
Released under the MIT License attached with this code.