Prerequisites
- PHP 8.1+ with
ip-api-io/ipapi-phpinstalled - A free ip-api.io API key
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']; 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" 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'];
}