PHP code example of unicodeveloper / laravel-email-validator

1. Go to this page and download the library: Download unicodeveloper/laravel-email-validator 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/ */

    

unicodeveloper / laravel-email-validator example snippets



// Laravel 5: config/app.php

'providers' => [
    ...
    Unicodeveloper\EmailValidator\EmailValidatorServiceProvider::class,
    ...
];


// Laravel 5: config/app.php

'aliases' => [
    ...
    'EmailValidator' => Unicodeveloper\EmailValidator\EmailValidatorFacade::class,
    ...
]

/**
 *  Config file that a user/developer can insert quickemailverficationservice api key
 */
return [
    'apiKey' => ''
];


 print_r(EmailValidator::verify('[email protected]')->isValid());
 // returns Array ( [0] => [1] => Could not get MX records for domain )
 
 print_r(EmailValidator::verify('[email protected]')->isValid());
 // returns Array ( [0] => 1 [1] => SMTP server accepted email address )

 var_dump( EmailValidator::verify('[email protected]')->isValid()[0]); 
 // returns bool(true)
 
 var_dump( EmailValidator::verify('[email protected]')->isValid()[0]); 
 // returns bool(false)
 
 
 if( EmailValidator::verify('[email protected]')->isValid()[0] ){
   ......
 }

 // returns a true/false if the email address is valid or not

/**
 * Returns true or false if the email address uses a disposable domain
 * @return boolean
 */
EmailValidator::verify('[email protected]')->isDisposable()

/**
 * Returns true or false if the API request was successful
 * @return boolean
 */
EmailValidator::verify('[email protected]')->apiRequestStatus()

/**
 * Get the domain of the provided email address
 * @return string
 */
EmailValidator::verify('[email protected]')->getDomainName()

/**
 * Get the local part of an email address
 * Example: [email protected] returns kkkkk
 * @return string
 */
EmailValidator::verify('[email protected]')->getUser()

/**
 * Gets a normalized version of the email address
 * Example: [email protected] returns [email protected]
 * @return string
 */
EmailValidator::verify('[email protected]')->getEmailAddress()

/**
 * Returns true if the domain appears to accept all emails delivered to that domain
 * @return boolean
 */
EmailValidator::verify('[email protected]')->acceptEmailsDeliveredToDomain()

/**
 * Returns true or false if email address is a role address
 * Example [email protected] , [email protected] will return true
 * @return boolean
 */
EmailValidator::verify('[email protected]')->isRole()
bash
php artisan vendor:publish