Email validation · Integrations · PHP
Integration guide
Email validation in PHP.
In this guide
How do I validate an email with PHP?
No SDK to install. cURL ships with PHP, and Guzzle is already in most Laravel and Symfony projects.
PHP, with Guzzle
use GuzzleHttp\Client;
function validateEmail(string $email): array
{
$client = new Client([
'base_uri' => 'https://api.trueguard.io',
'timeout' => 5.0,
]);
$res = $client->post('/v2/email/validation', [
'headers' => ['X-API-KEY' => getenv('TRUEGUARD_KEY')],
'json' => ['email' => $email],
]);
return json_decode((string) $res->getBody(), true);
}
$result = validateEmail('founder@yourcompany.com');
if ($result['deliverability']['status'] === 'invalid') {
// reject the submission
}One header, one body field
Set X-API-KEY to your key and POST a JSON body with a single email field. HTTPS only. The response carries the seven signals plus one deliverability status.
Response fields you will branch on
deliverability.statussafe, risky, invalid or unknown. This is the field to branch on.
syntax.isValidRFC 5322 format check. Deterministic, so a false here is always a typo or a malformed address.
quality.isDisposableTrue for throwaway providers. Usually a hard block at signup.
deliverability.isCatchallTrue when the domain accepts any address. The status is then risky, unless a second check confirmed or ruled out the mailbox.
quality.isRoleinfo@, support@, sales@. Route these differently rather than rejecting them.
Run it once before you write any code.
The same endpoint the snippet above calls. 10 free checks a day, no key needed.
Or try
Where should the call live in a PHP app?
Your API key is a secret. Where you put this call decides whether it stays one.
In a view or inline in a form template
Keep the key out of anything rendered and out of version control. Calling the endpoint from template code also makes the request impossible to cache, test or rate-limit sensibly.
In a service class, called from your controller
A Laravel form request rule or a Symfony validator constraint is the natural home. Read the key from the environment, call the service, and branch on the status before the model is persisted.
What the endpoint returns
{
"email": "founder@yourcompany.com",
"rawEmail": "founder@yourcompany.com",
"syntax": { "isValid": true },
"deliverability": {
"status": "safe",
"isSmtpValid": true,
"isMxValid": true,
"isCatchall": false,
"isInboxFull": false,
"isDeliverable": true,
"isDisabled": false,
"mxRecords": ["mx1.yourcompany.com", "mx2.yourcompany.com"]
},
"domain": {
"name": "yourcompany.com",
"age": 2841,
"isLive": true,
"isRisky": false
},
"quality": {
"isDisposable": false,
"isFree": false,
"isRole": false,
"isSubaddress": false
}
}How do I handle errors and rate limits in PHP?
use GuzzleHttp\Exception\RequestException;
try {
$result = validateEmail($email);
} catch (RequestException $e) {
$status = $e->getResponse()?->getStatusCode();
if ($status === 429) {
// quota or rate limit: allow with a flag
return allowWithFlag($email);
}
if ($status === 401) {
Log::error('Trueguard key rejected');
}
return allowWithFlag($email);
}Status
What to do
200Validation ran. Read deliverability.status and branch.
400Malformed request body. Check you are sending JSON with an email field.
401Missing or rejected API key. Log it loudly: every request is failing.
429Rate limit or monthly quota reached. Allow the user through with a flag and alert yourself; do not block real signups on your own quota.
5xxRetry once with a short backoff, then fall back to allowing with a flag.
Which PHP frameworks does this work with?
It is one HTTPS request, so anything that can make one works. These are the stacks people ask about.
Laravel validation rule
WordPress registration hook
CSV cleanup command
Symfony constraint
What it costs once you ship.
Three tiers. The free plan needs no card and runs the production endpoint.
Standard
Popular$49.99 / month
50,000 validations / month
Overage: $0.001 per validation
Get your API keyFrequently asked questions
The full field reference lives in the API documentation.
cURL or Guzzle?
Guzzle if your project already has it, which covers most Laravel and Symfony apps. Plain cURL is fine and adds no dependency: it is the same single POST either way.
Where does this belong in Laravel?
In a form request rule or a custom validation rule backed by a service class. The verdict is then available before the model is created and the message surfaces on the email field.
Can I use this in a WordPress plugin?
Yes, with wp_remote_post from the server side. Store the key with the plugin's options API, never in front-end script, and hook the check into registration or form submission.
What timeout should I set?
Around 5 seconds. Median response is under a second, but the SMTP step waits on the destination mail server. On timeout, allow with a flag rather than blocking a real signup.
Is there an official PHP SDK?
No. One header, one body field, one status to branch on, so a small service class is all it takes and there is nothing to keep updated.
Validate emails from PHP in minutes.
100 validations a month, free, no card. Working code above, production endpoint, same response shape on every plan.
Get your free API keyNo credit card required.

