PHP Classes

JsonEmail: Get the results of email validation in JSON format

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 144 All time: 9,153 This week: 524Up
Version License PHP version Categories
jsonemail 1.0BSD License7Web services, AJAX, PHP 7
Description 

Author

This package can get the results of email validation in JSON format.

It provides classes that take the results of a given email validation class and encode them as a JSON string so they can be returned as responses of applications that need to process the results in that format on the client side like AJAX applications and API based applications such as those that run on mobile devices.

The package provides wrapper classes for void and complex results and responses.

Picture of Dave Cobbe
Name: Dave Cobbe <contact>
Classes: 1 package by
Country: Switzerland Switzerland
Age: ???
All time rank: 428735 in Switzerland Switzerland
Week rank: 246 Up4 in Switzerland Switzerland Up

Example

<?php
header
( 'Content-Type:application/json;charset=utf-8' );
include_once(
'JsonReturn.class.php' );
$result = JsonReturn::onVoid();

if( !isset(
$_GET["email"]) ) {
   
$p_emailAddress = "void";
} else {
   
$p_emailAddress = urldecode( filter_input( INPUT_GET, "email", FILTER_SANITIZE_EMAIL ) );
}

if(
filter_var( $p_emailAddress, FILTER_VALIDATE_EMAIL ) ) {

    require_once(
'emailValidation.class.php' );
   
   
$validator = new email_validation_class;
   
$validator->timeout = 10;
   
$validator->data_timeout = 0;
   
$validator->localuser = "system.admin";
   
$validator->localhost = "victoriahome.ch";
   
$validator->debug = 0;
   
$validator->html_debug = 0;
   
$validator->exclude_address = "";
   
$validator->invalid_email_domains_file = 'resources/invalidemaildomains.csv';
   
$validator->invalid_email_servers_file = 'resources/invalidemailservers.csv';
   
$validator->email_domains_white_list_file = 'resources/emaildomainswhitelist.csv';
   
    if(
strlen( $errorCode = $validator->ValidateAddress( $p_emailAddress, $errorReturn ) ) ) {
       
$result = JsonReturn::onError( "Error: " . HtmlSpecialChars( $errorReturn ) );
    } else {
        if( !
$errorReturn ) {
            if(
count( $validator->suggestions ) ) {
               
$suggestion = $validator->suggestions[0];
               
$result = JsonReturn::onError( "Possible typo: did you mean " . HtmlSpecialChars( $suggestion ) . "?" );
            } else {
               
$result = JsonReturn::onError( HtmlSpecialChars( $p_emailAddress ) . " is not a valid deliverable e-mail address." );
            }
        } else {
            if( (
$deliverable = $validator->ValidateEmailBox( $p_emailAddress ) ) < 0 ) {
               
$result = JsonReturn::onError( "Warning: is was not possible to determine if " . HtmlSpecialChars( $p_emailAddress ) . " is a valid deliverable e-mail address." );
            } else {
                if( !
$deliverable ) {
                   
$result = JsonReturn::onError( "Error: " . HtmlSpecialChars( $p_emailAddress ) . " is not a deliverable e-mail address." );
                } else {
                   
$result = JsonReturn::onValue( $validator );
                }
            }
        }
    }

} else {
   
$result = JsonReturn::onError( "Syntax error found in email address." );
}

echo
$result->toString();
?>


  Files folder image Files  
File Role Description
Plain text file emailValidation.class.php Class Just an example of an email validation class (feel free to use others)
Plain text file JsonException.class.php Class Returns EXCEPTION object in JSON notation
Plain text file JsonReturn.class.php Class Returns an object in JSON notation.
Plain text file JsonVoid.class.php Class Returns VOID in JSON format
Accessible without login Plain text file validate.php Example Example file using JSON wrapper around an email validation class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:144
This week:0
All time:9,153
This week:524Up