PHP code example of dotmarn / mailcheckr-php

1. Go to this page and download the library: Download dotmarn/mailcheckr-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/ */

    

dotmarn / mailcheckr-php example snippets


use Dotmarn\MailCheckr\Facades\MailCheckr;

$verification = MailCheckr::verify(
    '[email protected]',
    'verify-user-123' // persist and reuse this key for retries of the same email
);

if ($verification->isPending()) {
    $verification = MailCheckr::find($verification->id()); // Poll later, not in a tight loop.
}

if ($verification->isDeliverable()) {
    // The verification completed and MailCheckr marked it deliverable.
} elseif ($verification->isUnknown()) {
    // The verification completed without a conclusive delivery result.
}

use Dotmarn\MailCheckr\MailCheckrClient;

$client = new MailCheckrClient();
$verification = $client->verify('[email protected]', 'verify-user-123');

if ($verification->isPending()) {
    $verification = $client->find($verification->id()); // Poll later, not in a tight loop.
}

if ($verification->isDeliverable()) {
    // The verification completed and MailCheckr marked it deliverable.
}

use Dotmarn\MailCheckr\WebhookVerifier;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::post('/webhooks/mailcheckr', function (Request $request, WebhookVerifier $verifier) {
    abort_unless($verifier->verify($request), 401);

    $event = $request->json()->all();
    // Deduplicate by $event['id'] in persistent storage before applying effects.

    return response()->noContent();
});
bash
composer