PHP code example of eg-mohamed / email-validation

1. Go to this page and download the library: Download eg-mohamed/email-validation 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/ */

    

eg-mohamed / email-validation example snippets


return [
    'validations' => [
        'syntax' => true,
        'dns' => true,
        'disposable' => true,
    ],
];

use Illuminate\Http\Request;

public function store(Request $request)
{
    $validated = $request->validate([
        'email' => ['

use MohamedSaid\EmailValidation\Rules\EmailValidationRule;

$request->validate([
    'email' => ['

use MohamedSaid\EmailValidation\Facades\EmailValidation;

if (EmailValidation::isValid('[email protected]')) {
    // Email is valid
}

$results = EmailValidation::validate('[email protected]');

$failures = EmailValidation::getFailures('[email protected]');

return [
    'validations' => [
        'syntax' => true,      // RFC syntax validation
        'dns' => true,         // DNS/MX record check
        'disposable' => true,  // Disposable email detection
    ],
];

return [
    'syntax' => 'The :attribute must be a valid email address.',
    'dns' => 'The :attribute domain does not have valid MX records.',
    'disposable' => 'Disposable email addresses are not allowed.',
];

return [
    'syntax' => 'يجب أن يكون :attribute عنوان بريد إلكتروني صالح.',
    'dns' => 'نطاق :attribute لا يحتوي على سجلات MX صالحة.',
    'disposable' => 'عناوين البريد الإلكتروني المؤقتة غير مسموح بها.',
];
bash
php artisan vendor:publish --tag="email-validation-config"
bash
php artisan vendor:publish --tag="email-validation-translations"