Knack ZeroBounce PHP API Wrapper
The recommended way to install Knack's ZeroBounce is through Composer. PHP 7.2+ Required.
composer require knack/zerobounce
<?php
use Knack\ZeroBounce\API\ZeroBounce;
use Knack\ZeroBounce\Enums\StatusEnum;
class EmailService {
/**
* @var ZeroBounce
*/
private $zeroBounce;
/**
* EmailService constructor.
*
* @param ZeroBounce $zeroBounce
*/
public function __construct(ZeroBounce $zeroBounce) {
$this->zeroBounce = $zeroBounce;
}
/**
* Validates an email address from blacklists and verifies that that domain is real.
*
* @param string $emailAddress
* @param string $ipAddress
*
* @return bool
*/
public function isValid(string $emailAddress, string $ipAddress = ''): bool
{
$response = $this->zeroBounce->validate($emailAddress, $ipAddress);
if($response->status === StatusEnum::VALID) {
return true;
}
return false;
}
}
<?php
use Knack\ZeroBounce\API\ZeroBounce;
use Knack\ZeroBounce\Enums\StatusEnum;
class EmailService {
/**
* @var ZeroBounce
*/
private $zeroBounce;
/**
* EmailService constructor.
*/
public function __construct() {
$this->zeroBounce = new ZeroBounce(getenv('ZEROBOUNCE_API_KEY'));
}
/**
* Validates an email address from blacklists and verifies that that domain is real.
*
* @param string $emailAddress
* @param string $ipAddress
*
* @return bool
*/
public function isValid(string $emailAddress, string $ipAddress = ''): bool
{
$response = $this->zeroBounce->validate($emailAddress, $ipAddress);
if($response->status === StatusEnum::VALID) {
return true;
}
return false;
}
}
To submit a Pull Request to this repo, just simply open up the Pull Request targeting develop
.
Please ensure all tests are passing prior to submitting your Pull Request.
composer test
Any of the following email addresses can be used for testing the API, no credits are charged for these test email addresses:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
You can this IP to test the GEO Location in the API.
- 99.110.204.1