1. Go to this page and download the library: Download truelist/truelist-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
truelist / truelist-php example snippets
use Truelist\Truelist;
$client = new Truelist('your-api-key');
$result = $client->validate('[email protected]');
if ($result->isValid()) {
echo "Email is valid!";
}
$client = new Truelist('your-api-key', [
'base_url' => 'https://api.truelist.io', // API base URL
'timeout' => 10, // Request timeout in seconds
'max_retries' => 2, // Retries on 429/5xx errors
'raise_on_error' => false, // Throw on transient errors
]);
$result = $client->validate('[email protected]');
$result->email; // '[email protected]'
$result->state; // 'ok', 'email_invalid', 'accept_all', 'unknown'
$result->subState; // 'email_ok', 'is_disposable', 'is_role', etc.
$result->suggestion; // Suggested correction or null
$result->domain; // 'example.com'
$result->canonical; // 'user'
$result->mxRecord; // MX record or null
$result->firstName; // First name or null
$result->lastName; // Last name or null
$result->verifiedAt; // ISO 8601 timestamp or null
$result = $client->validate('[email protected]');
// State checks
$result->isValid(); // true if state is 'ok'
$result->isInvalid(); // true if state is 'email_invalid'
$result->isAcceptAll(); // true if state is 'accept_all'
$result->isUnknown(); // true if state is 'unknown'
$result->isError(); // true if result came from a transient error
// Sub-state checks
$result->isRole(); // true if sub-state is 'is_role'
$result->isDisposable(); // true if sub-state is 'is_disposable'