Email Verification API - PHP Integration Guide 2026 | BounceZero
Blog›Developer Guides

Email Verification API
PHP Integration Guide 2026

Production-ready PHP code for BounceZero email verification - cURL single request, Guzzle HTTP client, Laravel custom validation rule, WordPress registration hook, WooCommerce checkout guard, and batch CSV processing.

By BounceZero Team |July 2026 |9 min read

Single Verification - PHP cURL

verify.php No dependencies
<?php

$apiKey = getenv("BOUNCEZERO_API_KEY");
$email  = "[email protected]";

function verifyEmail(string $email, string $apiKey): ?object {
    $ch = curl_init("https://api.bouncezero.io/api/v1/verify");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST           => true,
        CURLOPT_USERAGENT      => "MyApp/1.0", // requests without a User-Agent are rejected
        CURLOPT_POSTFIELDS     => json_encode(["email" => $email]),
        CURLOPT_HTTPHEADER     => [
            "X-API-Key: " . $apiKey,
            "Content-Type: application/json",
        ],
        CURLOPT_TIMEOUT        => 10,
    ]);
    $response = curl_exec($ch);
    $status   = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($status !== 200 || !$response) {
        return null; // fail open - do not block signup
    }
    return json_decode($response);
}

$result = verifyEmail($email, $apiKey);

if ($result) {
    echo $result->classification;                    // "valid" | "invalid"
    echo $result->score;                             // 0-100
    echo $result->metadata->internal_classification; // "verified", "catch_all", "disposable", ...
    echo !empty($result->metadata->refunded) ? "unverifiable (refunded)" : "checked";
}

Single Verification - Guzzle HTTP

verify_guzzle.php composer require guzzlehttp/guzzle
<?php

use GuzzleHttp\Client;

$apiKey = getenv("BOUNCEZERO_API_KEY");
$client = new Client(["base_uri" => "https://api.bouncezero.io"]);

function verifyEmail(string $email, string $apiKey, Client $client): ?object {
    try {
        $response = $client->post("/api/v1/verify", [
            "headers" => [
                "X-API-Key"     => $apiKey,
                "Content-Type"  => "application/json",
            ],
            "json" => ["email" => $email],
            "timeout" => 10,
        ]);
        return json_decode((string) $response->getBody());
    } catch (\Exception $e) {
        return null; // fail open
    }
}

$result = verifyEmail("[email protected]", $apiKey, $client);
echo $result?->classification; // "valid"

Laravel - Custom Validation Rule

app/Rules/BounceZeroEmail.php Laravel 9+
<?php

namespace App\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Http;

class BounceZeroEmail implements ValidationRule
{
    public function validate(string $attribute, mixed $value, Closure $fail): void
    {
        try {
            $response = Http::timeout(10)
                ->withHeaders(["X-API-Key" => config("services.bouncezero.key")])
                ->post("https://api.bouncezero.io/api/v1/verify", ["email" => $value])
                ->object();

            $internal = $response?->metadata?->internal_classification;
            if ($internal === "disposable") {
                $fail("Please use a work or personal email address.");
            } elseif ($response?->classification === "invalid" && empty($response?->metadata?->refunded)) {
                $fail("The :attribute does not appear to be a valid email address.");
            }
        } catch (\Exception) {
            // Fail open - never block signup on API error
        }
    }
}

// In config/services.php:
// "bouncezero" => ["key" => env("BOUNCEZERO_API_KEY")],

// In your Form Request:
// "email" => ["required", "email", new \App\Rules\BounceZeroEmail],

WordPress - Registration Hook

functions.php (or custom plugin)
<?php

add_filter("registration_errors", "bz_verify_registration_email", 10, 3);

function bz_verify_registration_email(WP_Error $errors, string $sanitized_user_login, string $user_email): WP_Error
{
    $api_key = defined("BOUNCEZERO_API_KEY") ? BOUNCEZERO_API_KEY : "";
    if (empty($api_key) || $errors->has_errors()) {
        return $errors; // skip if key not set or earlier errors present
    }

    $response = wp_remote_post("https://api.bouncezero.io/api/v1/verify", [
        "headers" => [
            "X-API-Key"     => $api_key,
            "Content-Type"  => "application/json",
        ],
        "body"    => json_encode(["email" => $user_email]),
        "timeout" => 10,
    ]);

    if (is_wp_error($response)) {
        return $errors; // fail open
    }

    $body = json_decode(wp_remote_retrieve_body($response));

    $internal = $body->metadata->internal_classification ?? "";
    if ($internal === "disposable") {
        $errors->add("disposable_email", __("<strong>Error</strong>: Please use a work or personal email address."));
    } elseif (($body->classification ?? "") === "invalid" && empty($body->metadata->refunded)) {
        $errors->add("invalid_email", __("<strong>Error</strong>: That email address doesn't appear to be valid."));
    }

    return $errors;
}

// In wp-config.php:
// define("BOUNCEZERO_API_KEY", "your_api_key_here");

API Response Reference

Field Type Values Use for
classification string valid / invalid Primary routing - suppress invalid
score int 0 - 100 Threshold filtering for catch-all decisions
metadata.internal_classification string verified / likely_valid / catch_all / invalid / disposable / risky / unknown Detailed reason, e.g. block disposable at signup
metadata.refunded bool true / null Could not be verified, credit auto-refunded
checks.domain_valid bool true / false Domain has active mail server
metadata.provider string mailbox provider name Provider-specific routing or personalisation

New to verification? Start with the complete email verification guide.

Frequently Asked Questions

How do I verify an email address in PHP?

Use cURL or Guzzle to POST to https://api.bouncezero.io/api/v1/verify with your API key in the X-API-Key header and {email: address} as JSON. Decode the response with json_decode() and check (valid or invalid) and ->internal_classification for the detailed reason. Always fail open on API errors (return null and continue) to avoid blocking legitimate signups.

How do I add email verification to a Laravel form?

Create a custom Rule class (php artisan make:rule BounceZeroEmail) that calls BounceZero via Laravel’s Http facade in the validate() method. Return () if classification is ‘invalid’ or metadata.internal_classification is ‘disposable’. Add new BounceZeroEmail to your Form Request rules for the email field.

How do I add email verification to a WordPress registration form?

Use the registration_errors filter hook. Call BounceZero with wp_remote_post() and check the response body. If invalid or disposable, add a WP_Error with (). WordPress blocks registration and displays the error. Always fail open (return unchanged) on wp_remote_post failures.

Get your API key and start verifying in 2 minutes.

100 free credits on signup. No credit card. Instant access. $3/1K thereafter - credits never expire. Works with any PHP 7.4+ application.

Build with the BounceZero API

Endpoints, code samples, and language guides