PHP code example of martian / spammailchecker

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

    

martian / spammailchecker example snippets


Martian\SpamMailChecker\SpamMailCheckerServiceProvider::class,

'SpamMailChecker' => Martian\SpamMailChecker\Facades\SpamMailChecker::class,

        'default' => 'local',
    

        'drivers' => [
            'local' => [
                ...
                'whitelist' => [
                    // Add domains you want the local driver to ignore here
                    'gmail.com',
                    'yahoo.com',
                ],
                'blacklist' => [
                    // Add domains you want the local driver to validate against here
                    'mailinator.com',
                    'spam.com',
                ],
            ]
        ]
    

        'driver' => 'remote',
    

        'drivers' => [
            ...
            'remote' => [
                ...
                'check_dns' => true, // When set to true, it will check for DNS
                'check_smtp' => false, // When set to true, it will check for SMTP
                'check_mx' => false, // When set to true, it will check for MX record
                'timeout' => 60 * 5, // 5 minutes
            ]
        ]
    

        'drivers' => [
            ...
            'abstractapi' => [
                ...
                'score' => 0.5, // 0.5 is the default score
                'accept_disposable_email' => true // When set to true, it will accept disposable email addresses
            ]
        ]
    

        'drivers' => [
            ...
            'quickemailverification' => [
                ...
                'accept_disposable' => true, // When set to true, it will accept disposable email addresses
            ]
        ]
    

        'drivers' => [
            ...
            'verifalia' => [
                ...
                'accept_disposable' => true, // When set to true, it will accept disposable email addresses
            ]
        ]
    

        'drivers' => [
            ...
            'sendgrid' => [
                ...
                'score' => 0.5, // 0.5 is the default score
                'accept_disposable' => true, // When set to true, it will accept disposable email addresses
                'source' => 'signup' // The source is signup by default
            ]
        ]
    

/**
 * Get a validator for an incoming registration request.
 *
 * @param  array  $data
 * @return \Illuminate\Contracts\Validation\Validator
 */
protected function validator(array $data)
{
    return Validator::make($data, [
        'email' => '

 /**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        'email' => '

    'email.spammail' => 'This email address is invalid.', // Custom error message

    'error_message' => 'This email address is invalid.', // Custom error message

use Martian\SpamMailChecker\SpamMailChecker;

public function checkEmail($email)
{
    $spamMailChecker = new SpamMailChecker();
    $spamMailChecker->validate($email);
}

use Martian\SpamMailChecker\Facades\SpamMailChecker;

public function checkEmail($email)
{
    SpamMailChecker::validate($email);
}

use Martian\SpamMailChecker\Drivers\VerifaliaDriver;

public function checkEmail($email)
{
    $verifaliaDriver = new VerifaliaDriver();
    $verifaliaDriver->validate($email);
}

use Martian\SpamMailChecker\Drivers\SendGridDriver;

public function checkEmail($email)
{
    $sendGridDriver = new SendGridDriver();
    $sendGridDriver->validate($email);
}

use Martian\SpamMailChecker\Drivers\AbstractApiDriver;

public function checkEmail($email)
{
    $abstractApiDriver = new AbstractApiDriver();
    $abstractApiDriver->validate($email);
}

use Martian\SpamMailChecker\Drivers\RemoteDriver;

public function checkEmail($email)
{
    $remoteDriver = new RemoteDriver();
    $remoteDriver->validate($email);
}

use Martian\SpamMailChecker\Drivers\LocalDriver;

public function checkEmail($email)
{
    $localDriver = new LocalDriver();
    $localDriver->validate($email);
}

use Martian\SpamMailChecker\Drivers\QuickEmailVerificationDriver;

public function checkEmail($email)
{
    $quickEmailVerificationDriver = new QuickEmailVerificationDriver();
    $quickEmailVerificationDriver->validate($email);
}
bash
php artisan vendor:publish --provider="Martian\SpamMailChecker\Providers\SpamMailCheckerServiceProvider"
bash
        php artisan optimize:clear