Kickbox – A Real-Time Email Verifier Library for PHP

Do you want to write a real-time email verifier script in PHP? A real email address means an email that actually exists. This email address is not a fake one. In this article, I show you how to write an email verifier script using Kickbox in PHP.

Why We Need to Check If Email Exists?

If you are running a membership site, then a user can register to your system by using a fake email address. Of course, we use the flow of an activation link before the user gets access to the system. But, it does not stop users from registering. Your database will have tons of useless records with these throw-away email addresses.

Another reason is email bouncing. While sending emails to invalid email addresses, you will face the problem of email bouncing as these emails do not really exist.

To avoid such problems, we should add an email verifier before users register to our application.

Kickbox provides an email verification service that helps to check if the email is valid or not. This service would act as a real-time email checker for our application.

Get Kickbox API Key

For implementing this library, you need to first create an account on Kickbox. Keep a note Kickbox offers 100 free email verifications. Check out their pricing page for additional quotas.

Once you created an account with Kickbox, login to your account, go to Account Settings->API Keys, and create API Key.

Create API Key in Kickbox

After creating the API key, you can view it by clicking on the eye icon next to the API Key field.


Email Verifier Script in PHP

As said we are going to write an email verifier script in PHP. Kickbox provides its official library for PHP. To install the Kickbox library, open the terminal in your project root directory and run the below command.

composer require kickbox/kickbox

Upon library installation, we are good to go ahead and write the actual code that checks if the email really exists.

require_once "vendor/autoload.php";
$client   = new Kickbox\Client('Kickbox_API_KEY');
$kickbox  = $client->kickbox();
try {
    $response = $kickbox->verify("EMAIL_ADDRESS");
    switch($response->code) {
        case 200:
            if ($response->body['result'] == 'deliverable') {
                echo "Valid Email.";
            } else {
                echo "Invalid Email.";
        case 429:
            echo "Rate limit exceeded.";
            echo "Something went wrong";
catch (Exception $e) {
    echo "Code: " . $e->getCode() . " Message: " . $e->getMessage();

Kickbox returns a response code 200 on success and 429 if you are exceeding the Rate Limit.

If the response code is 200 and the result is deliverable that means the email address is valid and it really exists.

I hope you understand how to write a real-time email verifier script in PHP. I would like to hear your thoughts or suggestions in the comment section below.

Related Articles

If you liked this article, then please subscribe to our YouTube Channel for video tutorials.

5 thoughts on “Kickbox – A Real-Time Email Verifier Library for PHP

Leave a Reply

Your email address will not be published. Required fields are marked *