PHP 7

You can find this User Contributed PHP7 wrapper below:

PrerequisitesYou need an active account at https://zerobounce.net to use this library. From there, grab your API Key under API - Keys & Info.

InstallationTo 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

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

usenickdnkZeroBounceEmail;usenickdnkZeroBounceResult;usenickdnkZeroBounceZeroBounce;// You can modify the timeout using the second parameter. Default is 15.$handler=newZeroBounce('my_api_key',30);$email=newEmail(// The email address you want to check'some-email@domain.com',// and if you have it, the IP address - otherwise null or omitted'123.123.123.123');try{// Validate the email$result=$handler->validateEmail($email);if($result->getStatus()===Result::STATUS_VALID){// All goodif($result->isFreeEmail()){// Email address is free, such as @gmail.com, @hotmail.com.}/** * 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();$user->getCountry();$user->getRegion();$user->getZipCode();$user->getCity();$user->getGender();$user->getFirstName();$user->getLastName();}elseif($result->getStatus()===Result::STATUS_DO_NOT_MAIL){// The substatus code will help you determine the exact issue:switch($result->getSubStatus()){caseResult::SUBSTATUS_DISPOSABLE:caseResult::SUBSTATUS_TOXIC:// Toxic or disposable.break;caseResult::SUBSTATUS_ROLE_BASED:// admin@, helpdesk@, info@ etc; not a personal emailbreak;// ... and so on.}}elseif($result->getStatus()===Result::STATUS_INVALID){// Invalid email.}elseif($result->getStatus()===Result::STATUS_SPAMTRAP){// Spam-trap.}elseif($result->getStatus()===Result::STATUS_ABUSE){// Abuse.}elseif($result->getStatus()===Result::STATUS_CATCH_ALL){// Address is catch-all; not necessarily a private email.}elseif($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: * https://www.zerobounce.net/docs/?swift#version-2__v2__ */}catch(ickdnkZeroBounceAPIError $exception){// Something happened. Perhaps a bad API key or insufficient credit.}