Our free API to validate e-mail addresses is really easy to use in PHP.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://mailcheck.p.rapidapi.com/?domain=EMAIL-OR-DOMAIN",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"x-rapidapi-host: mailcheck.p.rapidapi.com",
"x-rapidapi-key: YOUR-API-KEY"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
This will return a JSON-array with information about the domain, and if you should block it or not.
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://mailcheck.p.rapidapi.com/');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
'disable_test_connection' => 'true',
'domain' => 'EMAIL-OR-DOMAIN'
)));
$request->setHeaders(array(
'x-rapidapi-host' => 'mailcheck.p.rapidapi.com',
'x-rapidapi-key' => 'YOUR-API-KEY'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Unirest\Request::get("https://mailcheck.p.rapidapi.com/?domain=EMAIL-OR-DOMAIN",
array(
"X-RapidAPI-Host" => "mailcheck.p.rapidapi.com",
"X-RapidAPI-Key" => "YOUR-API-KEY"
)
);
You can of course just send it as a regular GET-request to that URL also, in your favorite way, as long as you have the API-key in the header.
You will receive a JSON response, telling you if this is a disposable e-mail to block, or if there are other issues with the domain:
{
"valid": true,
"block": true,
"disposable": true,
"domain": "nypato.com",
"text": "Disposable e-mail",
"reason": "Heuristics (1b)",
"risk": 91,
"mx_host": "mail57.nypato.com",
"mx_info": "Using MX pointer mail57.nypato.com from DNS with priority: 5",
"mx_ip": "109.236.80.110",
"last_changed_at": "2020-06-11T09:56:02+02:00"
}
This will tell you if you should block the domain nypato.com or not, and the reason to why the API thinks so (disposable e-mail, etc). You can also see more detailed documentation of the response here.
To get started for free, and get an API key, click here!