PHP Email verification Script

PHP Email verification Script

Overview

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_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
)








  • 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_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

  • 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

 

Original price was: $800.00.Current price is: $500.00.

Best Seller of Month Ideas for NFT Wallet

CONTACT US

SUBSCRIBE

Subscribe dolor sitamet, consectetur adiping eli. Duis esollici tudin augue.