Docs
Verify emails from PHP
A working helper that verifies one address from PHP. ValidReach does not publish an official SDK for this language. The examples call the REST API directly, which is the supported way to integrate.
Before you start
Create an API key under Settings → API keys and keep it in an environment variable named VALIDREACH_API_KEY on your server. Never ship it in browser or mobile code.
Verify one address
<?php
function verify(string $email): array {
$ch = curl_init('https://validreach.dev/api/v1/verify/single');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('VALIDREACH_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['email' => $email]),
]);
$raw = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code === 402) throw new RuntimeException('Out of credits');
if ($code === 429) throw new RuntimeException('Rate limited');
$body = json_decode($raw, true);
if (!($body['success'] ?? false)) {
throw new RuntimeException($body['message'] ?? 'Request failed');
}
return $body['data'];
}Handle the result
Branch on data.status. Treat invalid and disposable as rejections, retry unknown later when retryable is true (unknown is not billed), and decide on catchall, risky and role by your own policy. HTTP 402 means out of credits and 429 means rate limited.
Related