Validating email addresses

Top  Previous  Next

The EmailInspector class may be used to validate email addresses.  Several levels of email validation are provided, everything from basic syntax validation to more thorough user validation.

 

Example

 

EmailInspector insp = new EmailInspector();

//set the DNS server to be used for domain resolution

insp.setNameserver("ns.domain.com");

insp.setDebug(true);

 

// set the level of validation

insp.setEmailInspectionLevel(EmailInspector.USER_VALIDATION);

 

// perform validation of email address

try {

  insp.validate("user@domain.com");

} catch (Exception e) {

  e.printStackTrace(System.out); // validation failed

}

 

Validation levels

 

Level

Description

EmailInspector.SYNTAX_VALIDATION

Validates email address syntax only.

EmailInspector.DOMAIN_VALIDATION

Validates syntax and that domain portion of email address is a valid domain.

EmailInspector.MX_VALIDATION

Validates syntax, domain and that domain has a registered mail exchanger (MX) record.

EmailInspector.USER_VALIDATION

Validates syntax, domain, MX record and that when attempting to send email to registered MX server that it can connect and that server does not return an error when attempting to send email to specified email address.





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC