com.jscape.inspect

## Class EmailInspector

- java.lang.Object
- - com.jscape.inspect.EmailInspector

- All Implemented Interfaces:
    java.io.Serializable

      public class EmailInspector
      extends java.lang.Object
      implements java.io.Serializable

  Performs validation on an email address.

  Example Usage:

       // 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
       }

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    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 Summary

    Constructors
    Constructor and Description
    `EmailInspector()` Constructs a new EmailInspector instance.
    `EmailInspector(EmailInspectionLevel inspectionLevel, java.lang.String nameServer)` Constructs a new EmailInspector instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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`.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SYNTAX_VALIDATION

          public static final EmailInspectionLevel SYNTAX_VALIDATION

      Use in conjunction with `setEmailInspectionLevel` method to perform syntax validation of e-mail address.

    - #### DOMAIN_VALIDATION

          public static final EmailInspectionLevel DOMAIN_VALIDATION

      Use in conjunction with `setEmailInspectionLevel` method to perform syntax and domain validation of e-mail address.

    - #### MX_VALIDATION

          public static final EmailInspectionLevel MX_VALIDATION

      Use in conjunction with `setEmailInspectionLevel` method to perform syntax, domain and mail exchanger validation of e-mail address.

    - #### USER_VALIDATION

          public static final EmailInspectionLevel USER_VALIDATION

      Use in conjunction with `setEmailInspectionLevel` method to perform syntax, domain, mail exchanger and user validation of e-mail address.

  - ### Constructor Detail

    - #### EmailInspector

          public EmailInspector()

      Constructs a new EmailInspector instance.

    - #### EmailInspector

          public EmailInspector(EmailInspectionLevel inspectionLevel,
                                java.lang.String nameServer)

      Constructs a new EmailInspector instance.
      Parameters:
        `inspectionLevel` - the level of validation to perform
        `nameServer` - the DNS (Domain Name Server) used in performing domain lookup

  - ### Method Detail

    - #### getFromAddress

          public java.lang.String getFromAddress()

      Gets from address used when performing SMTP user validation.
      Returns:
        from address

    - #### setFromAddress

          public void setFromAddress(java.lang.String fromAddress)

      Sets from address used when performing SMTP user validation.
      Parameters:
        `fromAddress` - the from address

    - #### setDnsCache

          public void setDnsCache(java.io.File dnsCache)

      Sets locations of DNS cache file.
      Parameters:
        `dnsCache` - location of DNS cache file

    - #### getDnsCache

          public java.io.File getDnsCache()

      Gets location of DNS cache file.
      Returns:
        location of DNS cache file

    - #### setDnsCacheDays

          public void setDnsCacheDays(int dnsCacheDays)

      Sets the number of days in which DNS record may live in cache. Default is 30 days.
      Parameters:
        `dnsCacheDays` - DNS record cache lifetime in days

    - #### setIgnoreDnsResponseLength

          public void setIgnoreDnsResponseLength(boolean ignoreDnsResponseLength)

      Sets whether DNS response length header should be ignored when reading response. DNS queries are performed when doing DOMAIN or MX validation. Default is `false`.
      Parameters:
        `ignoreDnsResponseLength` - `false` if length header is ignored, `true` otherwise.

    - #### getIgnoreDnsResponseLength

          public boolean getIgnoreDnsResponseLength()

      Gets whether DNS response length header should be ignored when reading response. DNS queries are performed when doing DOMAIN or MX validation. Default is `false`.
      Returns:
        `false` if length header is ignored, `true` otherwise.

    - #### getDnsCacheDays

          public int getDnsCacheDays()

      Gets the number of days in which DNS record may live in cache. Default is 30 days.
      Returns:
        DNS record cache lifetime in days

    - #### setDebug

          public void setDebug(boolean debug)

      Sets debugging state. Default is `false`. Debugging messages are sent to System.out or alternative debugging stream.
      Parameters:
        `debug` - `true` if debug is enabled

    - #### getDebug

          public boolean getDebug()

      Gets debugging state. Default is `false`. Debugging messages are sent to System.out or alternative debugging stream.
      Returns:
        boolean `true` if debug is enabled

    - #### setDebugStream

          public void setDebugStream(java.io.PrintStream debugStream)

      Sets PrintStream used in reporting debug statements. Default PrintStream is System.out.
      Parameters:
        `debugStream` - the PrintStream to send debug statements to
      See Also:
        `PrintStream`

    - #### getDebugStream

          public java.io.PrintStream getDebugStream()

      Gets PrintStream used in reporting debug statements. Default PrintStream is System.out.
      Returns:
        the PrintStream used in debugging
      See Also:
        `PrintStream`

    - #### addDenyDomain

          public void addDenyDomain(java.lang.String domain)

      Adds domain to list of denied domains. This functionality is very useful in denying e-mail addresses from anonymous e-mail services.
      Parameters:
        `domain` - the domain to deny

    - #### addDenyDomain

          public void addDenyDomain(java.io.File file)
                             throws java.io.IOException

      Adds contents of file to list of domains to be denied. File should be in a format with one (1) domain per line. This functionality is very useful in denying e-mail addresses from anonymous e-mail services.
      Parameters:
        `file` - the domain file to add to denied domains list
      Throws:
        `java.io.IOException` - if an I/O error occurs

    - #### clearDenyDomain

          public void clearDenyDomain()

      Clears list of denied domains.

    - #### removeDenyDomain

          public void removeDenyDomain(java.lang.String domain)

      Removes a domain from list of denied domains.
      Parameters:
        `domain` - the domain to remove

    - #### getDenyDomain

          public java.util.Enumeration getDenyDomain()

      Gets an Enumeration of all denied domains.
      Returns:
        Enumeration domains

    - #### setNameserver

          public void setNameserver(java.lang.String nameServer)

      Sets the DNS (Domain Name Server) to be used in performing lookup on a domain. Name server may be represented as an IP address or hostname. Default is 127.0.0.1
      Parameters:
        `nameServer` - the DNS nameserver to use for domain queries

    - #### getNameserver

          public java.lang.String getNameserver()

      Gets the DNS (Domain Name Server) to be used in performing lookup on a domain. Name server may be represented as an IP address or hostname. Default is 127.0.0.1
      Returns:
        String nameServer

    - #### setEmailInspectionLevel

          public void setEmailInspectionLevel(EmailInspectionLevel inspectionLevel)

      Sets the validation level to be used in validating an e-mail address. Available validation levels levels are:`EmailInspector.SYNTAX_VALIDATION, EmailInspector.DOMAIN_VALIDATION, EmailInspector.MX_VALIDATION, EmailInspector.USER_VALIDATION, EmailInspector.ABSOLUTE_VALIDATION` Default validation level is `EmailInspector.SYNTAX_VALIDATION`.
      Parameters:
        `inspectionLevel` - the inspection level to use

    - #### getEmailInspectionLevel

          public EmailInspectionLevel getEmailInspectionLevel()

      Gets the validation level to be used in validating an e-mail address.
      Returns:
        EmailInspectionLevel inspectionLevel

    - #### validate

          public void validate(java.lang.String email)
                        throws InvalidEmailException

      Performs validation of e-mail address based on level of validation defined in call to `setEmailInspectionLevel`.
      Parameters:
        `email` - the email to validate
      Throws:
        `InvalidEmailException` - thrown if e-mail address is invalid

    - #### getTimeout

          public int getTimeout()

      Gets timeout in milliseconds for connecting to DNS and SMTP servers.
      Returns:
        timeout in milliseconds

    - #### setTimeout

          public void setTimeout(int timeout)

      Sets timeout in milliseconds for connecting to DNS and SMTP servers.
      Parameters:
        `timeout` - the timeout in milliseconds

    - #### getHeloAddress

          public java.lang.String getHeloAddress()

      Gets HELO hostname or IP address used when communicating with SMTP server. By default local hostname is used.
      Returns:
        the hostname or IP address to use

    - #### setHeloAddress

          public void setHeloAddress(java.lang.String heloAddress)

      Sets HELO hostname or IP address used when communicating with SMTP server. By default local hostname is used.
      Parameters:
        `heloAddress` - the hostname or IP address to use

Copyright © JSCAPE LLC. 1999-2021. All Rights Reserved