public class EmailInspector
extends java.lang.Object
implements java.io.Serializable
// create new instance EmailInspector insp = new EmailInspector(); // set the DNS server to be used for domain resolution insp.setNameserver("ns1.cox.west.net"); // set the level of validation insp.setEmailInspectionLevel(EmailInspector.DOMAIN_VALIDATION); // perform validation of email address try { insp.validate("user@domain.com"); } catch (Exception e) { e.prinStackTrace(System.out); // validation failed }
Modifier and Type | Field and Description |
---|---|
static EmailInspectionLevel |
DOMAIN_VALIDATION
Use in conjunction with
setEmailInspectionLevel method to perform syntax and domain validation of e-mail address. |
static EmailInspectionLevel |
MX_VALIDATION
Use in conjunction with
setEmailInspectionLevel method to perform syntax, domain and mail exchanger validation of e-mail address. |
static EmailInspectionLevel |
SYNTAX_VALIDATION
Use in conjunction with
setEmailInspectionLevel method to perform syntax validation of e-mail address. |
static EmailInspectionLevel |
USER_VALIDATION
Use in conjunction with
setEmailInspectionLevel method to perform syntax, domain, mail exchanger and user validation of e-mail address. |
Constructor and Description |
---|
EmailInspector()
Constructs a new EmailInspector instance.
|
EmailInspector(EmailInspectionLevel inspectionLevel,
java.lang.String nameServer)
Constructs a new EmailInspector instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addDenyDomain(java.io.File file)
Adds contents of file to list of domains to be denied.
|
void |
addDenyDomain(java.lang.String domain)
Adds domain to list of denied domains.
|
void |
clearDenyDomain()
Clears list of denied domains.
|
boolean |
getDebug()
Gets debugging state.
|
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debug statements.
|
java.util.Enumeration |
getDenyDomain()
Gets an Enumeration of all denied domains.
|
java.io.File |
getDnsCache()
Gets location of DNS cache file.
|
int |
getDnsCacheDays()
Gets the number of days in which DNS record may live in cache.
|
EmailInspectionLevel |
getEmailInspectionLevel()
Gets the validation level to be used in validating an e-mail address.
|
java.lang.String |
getFromAddress()
Gets from address used when performing SMTP user validation.
|
java.lang.String |
getHeloAddress()
Gets HELO hostname or IP address used when communicating with SMTP server.
|
boolean |
getIgnoreDnsResponseLength()
Gets whether DNS response length header should be ignored when reading response.
|
java.lang.String |
getNameserver()
Gets the DNS (Domain Name Server) to be used in performing lookup on a domain.
|
int |
getTimeout()
Gets timeout in milliseconds for connecting to DNS and SMTP servers.
|
void |
removeDenyDomain(java.lang.String domain)
Removes a domain from list of denied domains.
|
void |
setDebug(boolean debug)
Sets debugging state.
|
void |
setDebugStream(java.io.PrintStream debugStream)
Sets PrintStream used in reporting debug statements.
|
void |
setDnsCache(java.io.File dnsCache)
Sets locations of DNS cache file.
|
void |
setDnsCacheDays(int dnsCacheDays)
Sets the number of days in which DNS record may live in cache.
|
void |
setEmailInspectionLevel(EmailInspectionLevel inspectionLevel)
Sets the validation level to be used in validating an e-mail address.
|
void |
setFromAddress(java.lang.String fromAddress)
Sets from address used when performing SMTP user validation.
|
void |
setHeloAddress(java.lang.String heloAddress)
Sets HELO hostname or IP address used when communicating with SMTP server.
|
void |
setIgnoreDnsResponseLength(boolean ignoreDnsResponseLength)
Sets whether DNS response length header should be ignored when reading response.
|
void |
setNameserver(java.lang.String nameServer)
Sets the DNS (Domain Name Server) to be used in performing lookup on a domain.
|
void |
setTimeout(int timeout)
Sets timeout in milliseconds for connecting to DNS and SMTP servers.
|
void |
validate(java.lang.String email)
Performs validation of e-mail address based on level of validation defined in call to
setEmailInspectionLevel . |
public static final EmailInspectionLevel SYNTAX_VALIDATION
setEmailInspectionLevel
method to perform syntax validation of e-mail address.public static final EmailInspectionLevel DOMAIN_VALIDATION
setEmailInspectionLevel
method to perform syntax and domain validation of e-mail address.public static final EmailInspectionLevel MX_VALIDATION
setEmailInspectionLevel
method to perform syntax, domain and mail exchanger validation of e-mail address.public static final EmailInspectionLevel USER_VALIDATION
setEmailInspectionLevel
method to perform syntax, domain, mail exchanger and user validation of e-mail address.public EmailInspector()
public EmailInspector(EmailInspectionLevel inspectionLevel, java.lang.String nameServer)
inspectionLevel
- the level of validation to performnameServer
- the DNS (Domain Name Server) used in performing domain lookuppublic java.lang.String getFromAddress()
public void setFromAddress(java.lang.String fromAddress)
fromAddress
- the from addresspublic void setDnsCache(java.io.File dnsCache)
dnsCache
- location of DNS cache filepublic java.io.File getDnsCache()
public void setDnsCacheDays(int dnsCacheDays)
dnsCacheDays
- DNS record cache lifetime in dayspublic void setIgnoreDnsResponseLength(boolean ignoreDnsResponseLength)
false
.ignoreDnsResponseLength
- false
if length header is ignored, true
otherwise.public boolean getIgnoreDnsResponseLength()
false
.false
if length header is ignored, true
otherwise.public int getDnsCacheDays()
public void setDebug(boolean debug)
false
.
Debugging messages are sent to System.out or alternative debugging stream.debug
- true
if debug is enabledpublic boolean getDebug()
false
.
Debugging messages are sent to System.out or alternative debugging stream.true
if debug is enabledpublic void setDebugStream(java.io.PrintStream debugStream)
debugStream
- the PrintStream to send debug statements toPrintStream
public java.io.PrintStream getDebugStream()
PrintStream
public void addDenyDomain(java.lang.String domain)
domain
- the domain to denypublic void addDenyDomain(java.io.File file) throws java.io.IOException
file
- the domain file to add to denied domains listjava.io.IOException
- if an I/O error occurspublic void clearDenyDomain()
public void removeDenyDomain(java.lang.String domain)
domain
- the domain to removepublic java.util.Enumeration getDenyDomain()
public void setNameserver(java.lang.String nameServer)
nameServer
- the DNS nameserver to use for domain queriespublic java.lang.String getNameserver()
public void setEmailInspectionLevel(EmailInspectionLevel inspectionLevel)
EmailInspector.SYNTAX_VALIDATION, EmailInspector.DOMAIN_VALIDATION, EmailInspector.MX_VALIDATION, EmailInspector.USER_VALIDATION, EmailInspector.ABSOLUTE_VALIDATION
Default validation level is EmailInspector.SYNTAX_VALIDATION
.inspectionLevel
- the inspection level to usepublic EmailInspectionLevel getEmailInspectionLevel()
public void validate(java.lang.String email) throws InvalidEmailException
setEmailInspectionLevel
.email
- the email to validateInvalidEmailException
- thrown if e-mail address is invalidpublic int getTimeout()
public void setTimeout(int timeout)
timeout
- the timeout in millisecondspublic java.lang.String getHeloAddress()
public void setHeloAddress(java.lang.String heloAddress)
heloAddress
- the hostname or IP address to useCopyright © JSCAPE LLC. 1999-2021. All Rights Reserved