Composer dependency setup:
... "repositories": [{"type": "composer","url": "https://satis.firstbeatmedia.com/"}], "require": { "ValidateMyEmail/ApiClient": "~1.0" } ...
Using validate() method:
<?php
use ValidateMyEmail\ApiClient;
use ValidateMyEmail\ApiResponse;
$userEmail = 'mybox-mytag@yahoo.com';
$userId = 934422234232;
// validation
$api = new ApiClient('--YOUR-API-KEY-HERE--');
// uncomment if you don't want to queue validation and ready to wait up to 3 minutes (not recommended)
//$api->waitToComplete = true;
$validationLevel = 2;
$response = $api->validate($userEmail, $validationLevel, $userId);
if( !$response->isError )
{
if( $response->isValidationCompleted )
{
$emailReturned = $response->emailReturned;
if( !empty($emailReturned) and ($emailReturned != $userEmail))
{
replaceUserEmail($userEmail, $emailReturned); // replace user email with returned
}
switch($response->signal)
{
case ApiResponse::PASS:
// handle PASS signal
// mark email is valid
// send out mail
// complete registration / update
break;
case ApiResponse::BLOCK:
case ApiResponse::DO_NOT_SEND:
case ApiResponse::CUSTOM_X:
case ApiResponse::CUSTOM_Y:
case ApiResponse::CUSTOM_Z:
// handle BLOCK (or other blocking) signal:
// mark email as invalid
// ask user to provide valid email
// do not allow registration
//
break;
}
}
else
{
// validation not completed (queued)
$emailReturned = $response->emailReturned;
if( !empty($emailReturned) and ($emailReturned != $userEmail))
{
replaceUserEmail($userEmail, $emailReturned); // replace user email with returned
}
// continue, waiting for call-back or repeat validation after 3 minutes
}
}
else
{
$error = $response->errorString;
// handle VME error
// queue validation
// temporary disable VME integration
// check balance
}
Using queue() method and handling call-back request:
user_registration.php:
<?php
use ValidateMyEmail\ApiClient;
use ValidateMyEmail\ApiResponse;
$userEmail = 'mybox-mytag@yahoo.com';
$userId = 934422234232;
// validation
$api = new ApiClient('--YOUR-API-KEY-HERE--');
$validationLevel = 2;
$response = $api->queue($userEmail, $validationLevel, $userId);
if( !$response->isError )
{
// continue
// wait for call-back
// do not send to email until receiving call-back from VME
}
else
{
$error = $response->errorString;
// handle VME error
// re-queue validation
// temporary disable VME integration
// check balance
}
vme_callback_endpoint.php:
<?php
use ValidateMyEmail\ApiClient;
use ValidateMyEmail\ApiResponse;
$apiClient = new ApiClient('api-key');
$response = $apiClient->handleCallback();
ignore_user_abort(true);
header('Content-type: text/plain');
header("Content-Length: 2");
header("Connection: close", true);
echo('OK');
flush();
if( !$response->isError )
{
$emailReturned = $response->emailReturned;
$userId = intval($response->extraParameter);
if( !empty($emailReturned) and ($emailReturned != $userEmail))
{
replaceUserEmail($userEmail, $emailReturned); // replace user email with returned
}
switch($response->signal)
{
case ApiResponse::PASS:
// handle PASS signal
// mark email is valid
// send out mail
// complete registration / update
break;
case ApiResponse::BLOCK:
case ApiResponse::DO_NOT_SEND:
case ApiResponse::CUSTOM_X:
case ApiResponse::CUSTOM_Y:
case ApiResponse::CUSTOM_Z:
// handle BLOCK (or other blocking) signal:
// mark email as invalid
// ask user to provide valid email
// do not allow registration
//
break;
}
}
else
{
$error = $response->errorString;
// handle VME error
// temporary disable VME integration
// check balance
}
exit();
Using report() method:
<?php
use ValidateMyEmail\ApiClient;
use ValidateMyEmail\ApiResponse;
$apiClient = new ApiClient('--YOUR-API-KEY-HERE--');
$apiClient->report($userEmail, ApiClient::REPORT_OPEN_EMAIL);
// ...
$apiClient->report($userEmail2, ApiClient::REPORT_BOUNCE, 421, '4.7.0 [TS02] Messages from x.x.x.x temporarily deferred due to user complaints - 4.16.55');