PHP SDK · Feature

Email Validation & Verification in PHP

Check whether an email address is real, deliverable, and safe to accept — before it ever enters your database. The SDK exposes three levels: a fast syntax/MX/disposable check, full SMTP verification, and a batch endpoint for cleaning whole lists.

Trusted by thousands of businesses
Fast JSON API responses
Real-time validation
Simple integration, SDKs & examples
What it does

Three levels of email checking

Not every check needs an SMTP probe. emailInfo validates syntax and MX and flags disposable providers fast enough to run inline on a sign-up form. validateEmail goes further, connecting to the mail server to confirm the mailbox is deliverable and adding role-account, free-provider, and catch-all signals. validateEmailBatch applies that advanced check across an entire list in one request.

Prerequisites

1

Fast check with emailInfo

A lightweight check (no SMTP probe): validates syntax, confirms the domain has MX records, and flags disposable/throwaway providers. Use it inline on sign-up forms.

<?php

use IpApiIo\Client;

$client = new Client(apiKey: getenv('IP_API_IO_KEY'));

$info = $client->emailInfo('user@example.com');

var_dump($info['syntax']['is_valid']); // true
var_dump($info['is_disposable']);      // false
var_dump($info['has_mx_records']);     // true
echo $info['mx_records'][0]['hostname'];
2

Full SMTP verification with validateEmail

Advanced verification that connects to the mail server to confirm the mailbox is deliverable, and adds role-account, free-provider, catch-all and Gravatar signals.

$result = $client->validateEmail('user@example.com');

echo $result['reachable'];               // "yes" | "no" | "unknown"
var_dump($result['smtp']['deliverable']); // true
var_dump($result['smtp']['catch_all']);   // false
var_dump($result['disposable']);          // false
var_dump($result['role_account']);        // false  (e.g. info@, support@)
var_dump($result['free']);                // false  (e.g. gmail.com)
echo $result['suggestion'] ?? '';         // typo fix, e.g. "user@gmail.com"
3

Clean a list with validateEmailBatch

Advanced-validate up to 100 addresses in one request — the building block for email list cleaning. Throws an InvalidArgumentException if the array is empty or longer than 100.

$batch = $client->validateEmailBatch([
    'user@example.com',
    'fake@mailinator.com',
    'info@example.org',
]);

echo $batch['totalProcessed'];          // 3
echo $batch['successfulValidations'];   // 3

foreach ($batch['results'] as $email => $result) {
    echo $email, ' ', $result['reachable'], ' ', $result['disposable'];
}
Reference

Response reference

validateEmail response

FieldTypeDescription
emailstringThe address checked
reachablestring"yes", "no" or "unknown"
smtparray | nullhost_exists, deliverable, full_inbox, catch_all, disabled
gravatararray | nullhas_gravatar, gravatar_url
suggestionstringSuggested correction for a likely typo
disposableboolThrowaway provider
role_accountboolRole address (info@, sales@, …)
freeboolFree webmail provider
has_mx_recordsboolDomain can receive mail
FAQ

Frequently asked questions

How do I validate an email address in PHP?

For a fast check, call $client->emailInfo($email) — it validates syntax, confirms the domain has MX records, and flags disposable providers without an SMTP probe. For full deliverability, use $client->validateEmail($email), which connects to the mail server.

What's the difference between emailInfo and validateEmail?

emailInfo is a lightweight syntax/MX/disposable check, ideal inline on sign-up forms. validateEmail performs advanced SMTP verification and adds role-account, free-provider, catch-all and Gravatar signals — use it before sending important mail or accepting a paying customer.

How do I clean a whole list of emails?

Use $client->validateEmailBatch($emails) with up to 100 addresses per request — the building block for email list cleaning. It returns a results array of email to result and throws if the array is empty or longer than 100.

Can it detect disposable / throwaway emails?

Yes. Both emailInfo and validateEmail return a disposable flag (is_disposable / disposable) for throwaway providers like mailinator.com, so you can reject or down-rank them at sign-up.

Start building with the ip-api.io PHP SDK

Run composer require ip-api-io/ipapi-php, drop in your free API key, and ship in minutes — one zero-dependency client for geolocation, fraud detection, and email validation.

Need support?

Explore how IP-API.io can enhance your security, provide robust bot protection, and improve IP geolocation accuracy for your applications.

Contact Support

Found a bug in the SDK?

The ip-api-io/ipapi-php package is open source. Open an issue or pull request on GitHub and we'll take a look.

Open on GitHub