How to Comprehensively Validate an Email Address in PHP

Cloudmersive
1 min readMar 23, 2023

--

Data validation is an important step towards getting the most out of new contact information. Our Full Email Validation API can be used to check a new email’s syntactic correctness, identify the mail server (if any), and ping the email server to validate the existence of the account (without sending any emails!).

To take advantage of this API for free, all you need to do is follow steps to implement ready-to-run PHP code examples below. You’ll be done in minutes, and you can authenticate your API calls with a free-tier API key by quickly registering a free account on our website.

With our API key in hand, we can first install the SDK:

composer require cloudmersive/cloudmersive_validate_api_client

And then we can use the remaining code to structure our call:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');



$apiInstance = new Swagger\Client\Api\EmailApi(


new GuzzleHttp\Client(),
$config
);
$email = "email_example"; // string | Email address to validate, e.g. \"support@cloudmersive.com\". The input is a string so be sure to enclose it in double-quotes.

try {
$result = $apiInstance->emailFullValidation($email);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling EmailApi->emailFullValidation: ', $e->getMessage(), PHP_EOL;
}
?>

That’s all you need to do!

Note that with a free account, you’ll get a limit of 800 API calls per month, and once reached, that total will reset the following month (no additional commitments will be incurred).

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet