PHP code example of aman00323 / emailchecker

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

    

aman00323 / emailchecker example snippets


use Aman\EmailVerifier\EmailChecker;

$result = app(EmailChecker::class)->checkEmail('[email protected]', true);

if ($result['success']) {
	// Use $result['disposable'], $result['mxrecord'], $result['domain']
} else {
	// Use $result['error']
}



return [
    'smtp_probe' => env('EMAIL_CHECKER_SMTP_PROBE', true),
    'smtp_port' => (int) env('EMAIL_CHECKER_SMTP_PORT', 25),
    'smtp_timeout_seconds' => (int) env('EMAIL_CHECKER_SMTP_TIMEOUT_SECONDS', 5),
    'from_email' => env('EMAIL_CHECKER_SET_FROM', '[email protected]'),
];

$checker = app(EmailChecker::class);

$checker
    ->setSmtpProbeEnabled(false)
    ->setSmtpPort(2525)
    ->setSmtpTimeoutSeconds(10)
    ->setFromEmail('[email protected]');

app(EmailChecker::class)->checkDisposableEmail('[email protected]', true);

app(EmailChecker::class)->setFromEmail('[email protected]');

EMAIL_CHECKER_SET_FROM='[email protected]'

EMAIL_CHECKER_SMTP_PROBE=true
EMAIL_CHECKER_SMTP_PORT=25
EMAIL_CHECKER_SMTP_TIMEOUT_SECONDS=5

app(EmailChecker::class)->checkMxAndDnsRecord('[email protected]');

app(EmailChecker::class)->checkDomain('[email protected]');

app(EmailChecker::class)->checkEmail('[email protected]', true);

[
    'success' => true,
    'disposable' => ['success' => true, 'detail' => 'Email address is not disposable'],
    // Legacy key, kept for backward compatibility:
    'dispossable' => ['success' => true, 'detail' => 'Email address is not disposable'],
    'mxrecord' => ['success' => true, 'detail' => 'Valid email address'],
    'domain' => ['success' => true, 'detail' => 'Domain exists.'],
]
bash
php artisan vendor:publish --tag=emailchecker-config