1. Go to this page and download the library: Download bounceshift/bounceshift-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bounceshift / bounceshift-php example snippets
use BounceShift\Client;
$client = new Client(
apiKey: 'your-api-key',
organizationId: 'your-organization-id',
);
$result = $client->validate('[email protected]');
if ($result->isSafeToSend()) {
// status is `valid` or `catch_all`
}
echo $result->status->value; // e.g. "valid"
echo $result->confidence; // 0-100
$client = new Client('your-api-key', 'your-organization-id', [
'base_url' => 'https://api.bounceshift.com/v1', // default
'timeout' => 10, // seconds — max wait for a response (enforced)
'connect_timeout' => 5, // seconds — max wait to establish the connection
'retries' => 2, // retry attempts on 429 / 5xx
// Optionally inject your own PSR-18 / PSR-17 implementations:
// 'http_client' => $psr18Client,
// 'request_factory' => $psr17RequestFactory,
// 'stream_factory' => $psr17StreamFactory,
]);
$result = $client->validate('[email protected]');
if ($result->isSendable()) {
// recommendation is `deliverable` or `send_with_caution`
}
echo $result->recommendation?->value; // e.g. "deliverable", or null
echo $result->qualityScore; // 0-100, or null
echo $result->explanation; // plain-English verdict
$result = $client->validate('[email protected]');
if ($result->hasSuggestion()) {
// "[email protected]" — show it, don't swap it
echo $result->didYouMean;
}
use BounceShift\Exceptions\AuthenticationException;
use BounceShift\Exceptions\ForbiddenException;
use BounceShift\Exceptions\InsufficientCreditsException;
use BounceShift\Exceptions\RateLimitException;
use BounceShift\Exceptions\ApiException;
try {
$result = $client->validate('[email protected]');
} catch (AuthenticationException $e) { // 401
} catch (InsufficientCreditsException $e) { // 402
} catch (ForbiddenException $e) { // 403
} catch (RateLimitException $e) { // 429
$retryAfter = $e->retryAfter; // ?int seconds
} catch (ApiException $e) { // any other non-2xx
$status = $e->statusCode;
$body = $e->body;
}
$result = $client->validateSafe('[email protected]');
if ($result->isDegraded()) {
// We couldn't reach a verdict (out of credits / outage / timeout).
// The address is returned unverified — let it through, and alert your ops.
} elseif (! $result->isSafeToSend()) {
// A real verdict came back and it's not safe — reject as usual.
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.