Tutorial: How to Use an Email Verification API with PHP

Using an API for email verification involves sending a GET request to the API endpoint. Here's how you can do this using PHP:

                        

<?php
$email = 'Email_Address'; // Replace with the email you want to verify
$token = 'YOUR_API_KEY'; // Replace with your actual API key

$url = "https://api.ValidEmail.net/?email=$email&token=$token";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}

curl_close($ch);

$data = json_decode($result, true);

echo "Email is valid: " . ($data["IsValid"] ? 'Yes' : 'No') . "\n";
echo "Score: " . $data["Score"] . "\n";
echo "Email state: " . $data["State"] . "\n";
echo "Reason: " . $data["Reason"] . "\n";

foreach ($data["EmailAdditionalInfo"] as $info) {
    echo $info["Key"] . ": " . $info["Value"] . "\n";
}
?>
                    

Remember to replace 'Email_Address' and 'YOUR_API_KEY' with the actual email address you want to verify and your actual API key.