PHP Classes

Bulk Email Verifier PHP script with class PHP Email validation: Determine if a given e-mail address is valid.

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (48)   Blog (2)    
Last Updated Ratings Unique User Downloads Download Rankings
2024-02-07 (1 month ago) RSS 2.0 feedStarStarStarStar 61%Total: 35,910 All time: 12 This week: 50Down
Version License PHP version Categories
emailvalidation 1.0.19BSD License3Email, Networking, Validation
Description 

Author

Class that may be used to determine if a given e-mail address is valid. It features:

- Simple validation just by looking at the e-mail address string
- Validation of the domain against a list of known domains that are often misspelled (typos) like those of Gmail.com, Hotmail.com, Mail.ru, Ntlworld.com, Rediffmail.com, Rocketmail.com, Yahoo.com, Yandex.com, etc.
- Provides did you mean like suggestions for email addresses that were entered with typos
- Validation of domain against a list of typical fake domains like test.com, testtest.com, asd.com, asdf.com, etc..
- Validation of the email address domain against a list of of known domains for being used as disposable email addresses or temporary domains
- Manual whitelisting of domains to avoid trigger false positives of invalid domains
- Validation of the e-mail address domain checking the DNS MX record (mail exchange)
- Validation of a e-mail address by connecting to the mail host server to determine if there is really a deliverable mail box by simulating part of the message delivery process.

Picture of Manuel Lemos
  Performance   Level  
Name: Manuel Lemos is available for providing paid consulting. Contact Manuel Lemos .
Classes: 45 packages by
Country: Portugal Portugal
Age: 55
All time rank: 1
Week rank: 2 Down1 in Portugal Portugal Equal

Recommendations

What is the best PHP email verification class?
Bulk Verify Email Lists

What is the best PHP email address validation class?
Check if an email address exists

email validation
Bulk email validation

looking for email address verification script
can any one help me to find email verification php script

Find a php email validation class
I need to overcome malformed newlines in header

Example

<?php
/*
 * test_email_validation.html
 *
 * @(#) $Header: /opt2/ena/metal/emailvalidation/test_email_validation.php,v 1.14 2024/02/07 12:19:09 mlemos Exp $
 *
 */

?><html>
<head>
<title>Test for Manuel Lemos's PHP E-mail validation class</title>
</head>
<body>
<h1 align="center">Test for Manuel Lemos's PHP E-mail validation class</h1>
<hr>
<?php
   
require("email_validation.php");

   
$validator=new email_validation_class;

   
/* how many seconds to wait before each attempt to connect to the
       destination e-mail server */
   
$validator->timeout=10;

   
/* how many seconds to wait for data exchanged with the server.
       set to a non zero value if the data timeout will be different
         than the connection timeout. */
   
$validator->data_timeout=0;

   
/* user part of the e-mail address of the sending user
       (info@phpclasses.org in this example) */
   
$validator->localuser="info";

   
/* domain part of the e-mail address of the sending user */
   
$validator->localhost="phpclasses.org";

   
/* Set to 1 if you want to output of the dialog with the
       destination mail server */
   
$validator->debug=1;

   
/* Set to 1 if you want the debug output to be formatted to be
    displayed properly in a HTML page. */
   
$validator->html_debug=1;


   
/* When it is not possible to resolve the e-mail address of
       destination server (MX record) eventually because the domain is
       invalid, this class tries to resolve the domain address (A
       record). If it fails, usually the resolver library assumes that
       could be because the specified domain is just the subdomain
       part. So, it appends the local default domain and tries to
       resolve the resulting domain. It may happen that the local DNS
       has an * for the A record, so any sub-domain is resolved to some
       local IP address. This prevents the class from figuring if the
       specified e-mail address domain is valid. To avoid this problem,
       just specify in this variable the local address that the
       resolver library would return with gethostbyname() function for
       invalid global domains that would be confused with valid local
       domains. Here it can be either the domain name or its IP address. */
   
$validator->exclude_address="";
   
$validator->invalid_email_domains_file = 'invalidemaildomains.csv';
   
$validator->invalid_email_servers_file = 'invalidemailservers.csv';
   
$validator->email_domains_white_list_file = 'emaildomainswhitelist.csv';

    if(IsSet(
$_GET["email"]))
       
$email=$_GET["email"];
    if(IsSet(
$email)
    &&
strcmp($email,""))
    {
        if(
strlen($error = $validator->ValidateAddress($email, $valid)))
        {
            echo
"<h2 align=\"center\">Error: ".HtmlSpecialChars($error)."</h2>\n";
        }
        elseif(!
$valid)
        {
            echo
"<h2 align=\"center\"><tt>$email</tt> is not a valid deliverable e-mail box address.</h2>\n";
            if(
count($validator->suggestions))
            {
               
$suggestion = $validator->suggestions[0];
               
$link = '?email='.UrlEncode($suggestion);
                echo
"<H2 align=\"center\">Did you mean <a href=\"".HtmlSpecialChars($link)."\"><tt>".HtmlSpecialChars($suggestion)."</tt></a>?</H2>\n";
            }
        }
        elseif((
$result=$validator->ValidateEmailBox($email))<0)
            echo
"<h2 align=\"center\">It was not possible to determine if <tt>$email</tt> is a valid deliverable e-mail box address.</h2>\n";
        else
            echo
"<h2 align=\"center\"><tt>$email</tt> is ".($result ? "" : "not ")."a valid deliverable e-mail box address.</h2>\n";
    }
    else
    {
       
$email = 'your@test.email.here';
       
$link = '?email='.$email;
        echo
"<h2 align=\"center\">Access this page using passing the email to validate here: <a href=\"".HtmlSpecialChars($link)."\"><tt>".$email."</tt></a></h2>\n";
    }
?>
<hr>
</body>
</html>


Screenshots  
  • email_validation.gif
  Files folder image Files  
File Role Description
Accessible without login Plain text file test_email_validation.php Example E-mail validation test page script
Accessible without login Plain text file invalidemaildomains.csv Data Sample list of domains known to be invalid for email addresses
Accessible without login Plain text file emaildomainswhitelist.csv Data White list of domains to always be considered valid
Plain text file email_validation.php Class E-mail validation class
Accessible without login Plain text file invalidemailservers.csv Data Invalid email servers list
Accessible without login Plain text file invalidemailusers.csv Data List of invalid email address user names

Downloademailvalidation-2024-02-07.zip 20KB
Downloademailvalidation-2024-02-07.tar.gz 20KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
DNSResolver Download .zip .tar.gz If you are using Windows or any other platform on which the PHP function GetMXRR is not working, this class can provide an alternative Conditional
 Version Control Reuses Unique User Downloads Download Rankings  
 28%1
Total:35,910
This week:0
All time:12
This week:50Down
User Ratings User Comments (8)
 All time
Utility:89%StarStarStarStarStar
Consistency:82%StarStarStarStarStar
Documentation:-
Examples:81%StarStarStarStarStar
Tests:-
Videos:-
Overall:61%StarStarStarStar
Rank:1074
 
By this code i am able to validate only domain, not validate ...
11 months ago (icert glob)
45%StarStarStar
Thank you very useful package
3 years ago (Alberto Garelli)
70%StarStarStarStar
Your class stays in conflict with the Single Responsibility P...
7 years ago (Matthias Kaschubowski)
40%StarStarStar
Amazing and very Simple to use! I have seen a few Text Tutori...
9 years ago (Miklo)
70%StarStarStarStar
The class is very helpful for me.
11 years ago (Khoa Nguyen)
70%StarStarStarStar
Excellent
14 years ago (kishore kumar)
70%StarStarStarStar
Tried the ValidateEmailAddress() method to no avail.
16 years ago (G. S.)
35%StarStar
very useful script
15 years ago (Lee J)
70%StarStarStarStar