Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

ZeroBounce PHP Library

This library will allow you to integrate the ZeroBounce API in your project using modern PHP7 and an OOP structure.


You need an active account at to use this library. From there, grab your API Key under API - Keys & Info.


To include this in your project, install it using Composer.

As we use return types and type hints, this library requires PHP 7.1.

composer require nickdnk/zerobounce-php


Enter your API key into the ZeroBounceTest file and run it. This uses the test-emails supplied by ZeroBounce and will not cost you credit.

How to use

use nickdnk\ZeroBounce\Email;
use nickdnk\ZeroBounce\Result;
use nickdnk\ZeroBounce\ZeroBounce;

// You can modify the timeout using the second parameter. Default is 15.
$handler = new ZeroBounce('my_api_key', 30);

$email = new Email(
    // The email address you want to check
    // and if you have it, the IP address - otherwise null or omitted


try {

    // Validate the email
    $result = $handler->validateEmail($email);
    if ($result->getStatus() === Result::STATUS_VALID) {
        // All good
        if ($result->isFreeEmail()) {
            // Email address is free, such as,
        * The user object contains metadata about the email address
        * supplied by ZeroBounce. All of these may be null or empty
        * strings, so remember to check for that. 
        $user = $result->getUser();
    } else if ($result->getStatus() === Result::STATUS_DO_NOT_MAIL) {
        // The substatus code will help you determine the exact issue:
        switch ($result->getSubStatus()) {
            case Result::SUBSTATUS_DISPOSABLE:
            case Result::SUBSTATUS_TOXIC:
                // Toxic or disposable.
            case Result::SUBSTATUS_ROLE_BASED:
                // admin@, helpdesk@, info@ etc; not a personal email
            // ... and so on.
    } else if ($result->getStatus() === Result::STATUS_INVALID) {
        // Invalid email.
    } else if ($result->getStatus() === Result::STATUS_SPAMTRAP) {
        // Spam-trap.
    } else if ($result->getStatus() === Result::STATUS_ABUSE) {
        // Abuse.
    } else if ($result->getStatus() === Result::STATUS_CATCH_ALL) {
        // Address is catch-all; not necessarily a private email.
    } else if ($result->getStatus() === Result::STATUS_UNKNOWN) {
        // Unknown email status.
     * To find out how to use and react to different status and
     * substatus codes, see the ZeroBounce documentation at:

} catch (\nickdnk\ZeroBounce\APIError $exception) {

   // Something happened. Perhaps a bad API key or insufficient credit.



nickdnk (at)

Use this library at your own risk. PRs are welcome :)

You can’t perform that action at this time.