Sign Up Free

PHP Email Verification SDK — Verify Emails in PHP

Everything you need to integrate email verification into your application.

Getting Started

The official PHP SDK provides an object-oriented interface for email verification. Supports PHP 7.4+ including 8.x, uses Guzzle for HTTP, and follows PSR-4 autoloading.

Install via Composer and verify with a clean OOP interface. Includes a Laravel service provider and custom validation rule. Visit our email verifier for web-based verification.

Code Example

composer require ev-ecomtechbd/php-sdk

<?php
use EvEcomtechbd\EmailVerifier;

$verifier = new EmailVerifier('YOUR_API_KEY');
$result = $verifier->verify('user@example.com');

echo $result->status;      // "deliverable"
echo $result->score;       // 95
echo $result->disposable;  // false

// Laravel usage
// In config/services.php:
// 'ev' => ['key' => env('EV_API_KEY')]
// In controller:
// $result = app(EmailVerifier::class)->verify($email);

Authentication & Setup

Install: composer require ev-ecomtechbd/php-sdk. For Laravel, publish the config. Set API key in .env as EV_API_KEY. Includes a custom validation rule: validates :email, email_verification: true.

Getting Started

Install the PHP email verification SDK using Composer by running composer require ev-ecomtechbd/php-sdk in your project root. The package requires PHP 7.4 or higher, including PHP 8.0, 8.1, 8.2, and 8.3. It uses Guzzle as its HTTP client and follows PSR-4 autoloading conventions. If your project already uses Guzzle, the SDK will use the version you have installed. For Laravel projects, the SDK includes a service provider that is auto-discovered, so no additional registration is required after installation.

After installing, create an instance of EmailVerifier with your API key. For Laravel applications, add EV_API_KEY to your .env file and run php artisan vendor:publish --tag=ev-config to publish the configuration file. The SDK will automatically read the key from your environment. For standalone PHP projects, pass the API key directly to the constructor or set it as an environment variable. The constructor accepts an optional configuration array where you can set timeout, retries, sandbox mode, and a custom base_url. The client uses connection pooling via Guzzle and is safe to reuse across requests in long-running processes.

Code Examples

Single Email Verification

<?php
require_once 'vendor/autoload.php';

use EvEcomtechbd\EmailVerifier;

$verifier = new EmailVerifier(getenv('EV_API_KEY'));
$result = $verifier->verify('user@example.com');

echo $result->email;         // "user@example.com"
echo $result->status;        // "deliverable"
echo $result->score;         // 95
echo $result->disposable;    // false
echo $result->roleAccount;   // false
echo $result->mxFound;       // true
echo $result->smtpProvider;  // "google"

Batch Email Verification

<?php
use EvEcomtechbd\EmailVerifier;

$verifier = new EmailVerifier('YOUR_API_KEY');

// Submit a batch of emails
$emails = ['alice@example.com', 'bob@company.org', 'test@temp-mail.io'];
$job = $verifier->verifyBatch($emails);
echo "Job ID: " . $job->id . "\n";

// Wait for batch completion with polling
$results = $verifier->waitForBatch($job->id, [
    'poll_interval' => 5,   // seconds between checks
    'timeout' => 600        // max wait time in seconds
]);

// Process results
foreach ($results as $result) {
    echo "{$result->email}: {$result->status} (score: {$result->score})\n";
}

// Filter deliverable emails
$valid = array_filter($results, fn($r) => $r->status === 'deliverable');
echo "Valid emails: " . count($valid) . "\n";

Laravel Integration

<?php
// In a Laravel controller
namespace App\Http\Controllers;

use EvEcomtechbd\EmailVerifier;
use Illuminate\Http\Request;

class RegistrationController extends Controller
{
    public function register(Request $request, EmailVerifier $verifier)
    {
        $request->validate([
            'email' => 'required|email|ev_deliverable',
        ]);

        $result = $verifier->verify($request->email);

        if ($result->status !== 'deliverable') {
            return back()->withErrors(['email' => 'Please use a valid email.']);
        }

        // Proceed with registration
    }
}

Error Handling

The PHP SDK throws specific exception classes for each error type. The base class EvException is extended by AuthenticationException for invalid API keys, RateLimitException for quota overages, ValidationException for malformed input, and NetworkException for connectivity problems. Each exception includes a getStatusCode() method and a getErrorCode() method for programmatic handling. In Laravel, these exceptions can be mapped to custom error pages in your exception handler.

Rate limiting is handled automatically by the SDK, which retries requests with exponential backoff when a 429 response is received. You can configure the maximum number of retries via the retries option in the constructor. The RateLimitException provides a getRetryAfter() method returning the number of seconds to wait. For batch operations, individual failures are recorded in each result's error property without halting the overall job. Use $verifier->getRateLimitRemaining() to check your remaining quota between requests and throttle accordingly.

<?php
use EvEcomtechbd\EmailVerifier;
use EvEcomtechbd\Exceptions\AuthenticationException;
use EvEcomtechbd\Exceptions\RateLimitException;
use EvEcomtechbd\Exceptions\ValidationException;
use EvEcomtechbd\Exceptions\EvException;

$verifier = new EmailVerifier('YOUR_API_KEY', ['retries' => 3]);

try {
    $result = $verifier->verify('user@example.com');
    echo "Status: {$result->status}\n";
} catch (RateLimitException $e) {
    echo "Rate limited. Retry after {$e->getRetryAfter()} seconds.\n";
} catch (AuthenticationException $e) {
    echo "Invalid API key. Check your EV_API_KEY.\n";
} catch (ValidationException $e) {
    echo "Invalid input: {$e->getMessage()}\n";
} catch (EvException $e) {
    echo "Error: {$e->getMessage()} (code: {$e->getErrorCode()})\n";
}

Frequently Asked Questions

The SDK supports PHP 7.4 and above, including PHP 8.x. It uses Guzzle HTTP client for requests and follows PSR-4 autoloading. Install via Composer with composer require ev-ecomtechbd/php-sdk.

Yes, the SDK includes a Laravel service provider for automatic dependency injection. Add the service provider to your config/app.php, publish the config file, and inject the EmailVerifier class into your controllers or form requests. A custom validation rule is also included.

The SDK throws typed exceptions: InvalidApiKeyException, RateLimitException, ValidationException, and NetworkException. Wrap API calls in try-catch blocks to handle specific error types. Each exception includes the HTTP status code, error message, and request ID for debugging.

Start Verifying Emails Today

100 daily free verifications. No credit card required. Full API access on all plans. Visit our email verifier to get started.

Try our free email verifier — verify any email instantly, no signup required. Need bulk verification? Upload your list and clean thousands of emails in minutes.

Developers: integrate email verification into your app with our RESTful API — SDKs for 7 languages.

Free tools: SPF checker · DKIM checker · SMTP tester