PHP code example of raul3k / disposable-email-blocker-laravel
1. Go to this page and download the library: Download raul3k/disposable-email-blocker-laravel 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/ */
raul3k / disposable-email-blocker-laravel example snippets
use Raul3k\DisposableBlocker\Laravel\Rules\NotDisposableEmail;
// In a Form Request
public function rules(): array
{
return [
'email' => [''email' => ['
use Raul3k\DisposableBlocker\Laravel\Facades\DisposableEmail;
// Simple check
if (DisposableEmail::isDisposable($email)) {
return back()->withErrors(['email' => 'Disposable emails not allowed']);
}
// Get detailed result
$result = DisposableEmail::check($email);
$result->isDisposable(); // bool
$result->isSafe(); // bool
$result->getDomain(); // string
$result->getConfidence(); // float
// Check domain directly
DisposableEmail::isDomainDisposable('mailinator.com'); // true
// Batch checking
$results = DisposableEmail::checkBatch([
'[email protected] ',
'[email protected] ',
]);
// Domain information
$info = DisposableEmail::info('[email protected] ');
$info->domain(); // 'example.co.uk'
$info->subdomain(); // 'mail'
$info->publicSuffix(); // 'co.uk'
$info->isPrivate(); // false
// config/disposable-blocker.php
return [
// Checker type: 'file', 'database', 'pattern', 'chain'
'checker' => env('DISPOSABLE_CHECKER', 'file'),
// Use bundled list from core package
'use_bundled_list' => true,
// Enable pattern-based detection
'pattern_detection' => false,
// Domains to whitelist (never block)
'whitelist' => [
// 'mycompany.com',
],
// Cache settings
'cache' => [
'enabled' => true,
'store' => env('DISPOSABLE_CACHE_STORE', 'default'),
'ttl' => 3600,
'prefix' => 'disposable_email:',
],
// Database settings (when checker = 'database')
'database' => [
'table' => 'disposable_domains',
'connection' => null,
],
];
'checker' => 'file',
'use_bundled_list' => true,
'checker' => 'database',
'checker' => 'chain',
'use_bundled_list' => true,
'pattern_detection' => true,
bash
php artisan vendor:publish --tag=disposable-blocker-config
bash
php artisan vendor:publish --tag=disposable-blocker-migrations
php artisan migrate
bash
php artisan vendor:publish --tag=disposable-blocker-migrations
php artisan migrate
php artisan disposable:update
bash
composer analyse