PHP Classes

PHP Email Validation Quality: Validate email address and compute quality score

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 698 This week: 1All time: 4,693 This week: 560Up
Version License PHP version Categories
mailboxlayer 1.1GNU General Publi...5Email, PHP 5, Web services, Validation
Description 

Author

This class can validate email address and compute quality score.

It can send a HTTP request to the mailboxlayer API Web server to validate a given email address.

The mailboxlayer API can check the email domain MX records to connect to the domain SMTP server and depending on the response returns a quality score for the validity of the email address.

Picture of Dave Smith
  Performance   Level  
Name: Dave Smith is available for providing paid consulting. Contact Dave Smith .
Classes: 51 packages by
Country: United States United States
Age: 58
All time rank: 618 in United States United States
Week rank: 20 Up3 in United States United States Up
Innovation award
Innovation award
Nominee: 32x

Winner: 7x

Recommendations

verify email if it fake or real
i wanna verify email if it fake or real

Example

<?php

//include the class
include('mailboxlayer.class.php');

//instantiate the class
$mbox = new mailBoxLayer();

//email address to check
$email = 'test@domain.com';

if(
$mbox->verifyMail($email) === false ){
   
//an error occured
   
   
echo 'The request returned an error -> ['.$mbox->errorCode.'] '.$mbox->errorText;
   
}else{
   
    if( empty(
$mbox->response->format_valid ) ){
       
        echo
'Not a properly formatted e-mail address<br>';
       
    }else{
       
        echo
'Properly formatted e-mail address<br>';
       
    }
   
    if( !empty(
$mbox->response->did_you_mean) ){
       
        echo
'Possibly the correct e-mail address is: '.$mbox->response->did_you_mean.'<br>';
       
    }
   
    if( empty(
$mbox->response->mx_found) ){
       
        if(
$mbox->response->mx_found === null ){
           
            echo
'mx record not checked<br>';
           
        }else{
           
            echo
'mx record not found<br>';
           
        }
       
    }else{
       
        echo
'mx record found<br>';
       
    }
   
    if( empty(
$mbox->response->smtp_check) ){
       
        if(
$mbox->response->smtp_check === null ){
           
            echo
'smtp server not checked<br>';
           
        }else{
           
            echo
'smtp server not found<br>';
           
        }
       
    }else{
       
        echo
'smtp server found';
       
    }
   
    echo
'score = '.$mbox->response->score.'<br>';
   
$quality = $mbox->response->score * 100;
   
   
//suggested transactional quality
   
echo 'Quality is ';
    if(
$quality < 33 ){
       
        echo
'bad<br>';
       
    }elseif(
$quality < 65 ){
       
        echo
'moderate<br>';
       
    }else{
       
        echo
'good<br>';
       
    }
   
}

var_dump($mbox->response);
/*
a validation request will return the following object properties

email - email address to verify
did_you_mean - suggested correct email, if any
user - user name part of email
domain - domain part of email
format_valid - true/false, true if valid email format
mx_found - true/false/null - true if mx record found, null if not checked
smtp_check - true/false/null - true if smtp server found, null if not checked
catch_all - true/false - true if catch all email
role - true/false - true if role specific email
disposable = true/false - true if disposable email
free = true/false - true if free service provider
score = quality score between 0 and 1
*/

?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Usage
Accessible without login Plain text file license.txt Lic. License
Plain text file mailboxlayer.class.php Class Main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:698
This week:1
All time:4,693
This week:560Up