PHP Email verification ScriptPHP Email verification Script
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 Average rating of 5.0 based on 1 votesPHP Email verification Script
Email verification is a PHP class that can be easily used to verify an email address and make sur... Average rating of 5.0Overview
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.
Features
- Check email syntax
- Check MX records
- Check SMTP mailbox actual existence
- Detect disposable mail
- Detect role-based mail
Requirements
- PHP 5.x
- PHP 7.x
- Port for checking SMTP is opened, e.g: 25, 465, 587
Instructions
Script Structure
When you open up my script folder, you’ll see the following files and directories:
- inc/
- disposable-domains.php
- email-verification.class.php
- role-based.php
- index.php
- bulk.php
- bulk-ajax.php
- cli.php
- README.docx
The file & folders
- inc: Contains the common files, where all the logic live here.
- index.php: A simple form with Bootstrap style for verifing email exist or not.
- cli.php: A simple file allow you verify email in command line directly.
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 protected]', [email protected]');
Or you can specify other port number to check than 25:
$ev = new EmailVerification(‘[email protected]', [email protected]', 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 protected]', 'format_valid' => true, 'mx_found' => true, 'smtp_check' => true, 'catch_all' => true, 'role' => false, 'disposable' => false )
- email: this field contain the value of checking email
- format_valid: this field indicate that email has valid syntax or not.
- mx_found: this field indicate that email has MX records or not.
- smtp_check: this field indicate that email actual exist or not.
- catch_all: this field indicate that email server of checking email has setup catch all or not.
- role: this field indicate that email is role-based or not.
- disposable: this field indicate that email is using disposable email service or not.
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 protected], verifier email = [email protected], port = 25', 1 => 'Email was set to [email protected]', 2 => 'Verifier email was set to [email protected]', 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
2. Via web browser: Open your favorite browser and enter the path to index.php, example: http://localhost/verify-email then enter needed information to check
Notes
- Some mail servers will reject the test message to prevent spammers from checking against their users' emails and filter the valid emails, so this script might not work properly with all mail servers
- You server should be configured properly as a mail server to avoid being blocked or blacklisted
Reviews
Other items by this author
PHP Script Installation Service
Don't worry about the installation of your script! Have your PHP Script installed for you.
|
$39 | Buy now |
Category | Scripts & Code / PHP Scripts / Security |
First release | 29 January 2021 |
Last update | 5 August 2022 |
Software version | PHP 7.0, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, PHP 8.0, PHP 5.x |