![]()
Email verification is a PHP class that can be easily used to verify an email address and make sure it is valid and does exist on the mail server.
In addition to checking the syntax, the actual existence of an email address using MX-Records and the Simple Mail Transfer Protocol (SMTP), and detecting whether or not the requested mailbox is configured to catch all incoming mail traffic, is disposable mail or role-based email.
Script Structure
When you open up my script folder, you’ll see the following files and directories:
The file & folders
How to install
Add this class to your file:
require_once './inc/email-verification.class.php';
That’s all, now you are ready to use that class!
How to use
Initialize the class:
$ev = new EmailVerification(‘email_to_check@example.com', verifier_email@gmail.com');
Or you can specify other port number to check than 25:
$ev = new EmailVerification(‘email_to_check@example.com', verifier_email@gmail.com', 465);
You can also modify/set the values of email to verify, verifier email, and port number on the fly after initializing:
$ev->setEmail('<another email Address to verify>');
$ev->setVerifierEmail('<another verifier email>');
$ev->setPort(<port number>);
Then you call the verify function: $ev->verify();
This will return an array:
array ( 'email' => 'email_to_check@example.com', 'format_valid' => true, 'mx_found' => true, 'smtp_check' => true, 'catch_all' => true, 'role' => false, 'disposable' => false )
If you want to get all debug messages while checking email, call this function: $ev->getDebugInfo(); which will return an array:
array ( 0 => 'Initialized with values: email = email_to_check@example.com, verifier email = verifier_email@gmail.com, port = 25', 1 => 'Email was set to email_to_check@example.com', 2 => 'Verifier email was set to verifier_email@gmail.com', 3 => 'Port was set to 25', 4 => 'Verify function was called.', 5 => 'Finding MX record...', 6 => 'No MX record was found.', )
There are two examples of this script that you can run:
1. Command line: just simple open a terminal and type:
php cli.php -e <the email to be checked> -v <the email to be provided to server> -p <port number>
or
php cli.php --email <the email to be checked> --verifier-email <the email to be provided to server> --port <port number>
Which:
-e, –email: is the email that you want to check
-v, –verifier-email: is an email address to be provided to the server. This email needs to be valid and from the same server that the script is running from.
-p, –port: is the SMTP port to check
Notes
$800.00 Original price was: $800.00.$500.00Current price is: $500.00.


