PHP code example of phpexperts / neverbounce

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

    

phpexperts / neverbounce example snippets


    // Build the client.
    $client = NeverBounceClient::build();
    
    // Quickly determine if an email is valid or not.
    $response = $client->isValid('[email protected]');
    // Output: true or false
    
    // Get details as to why an email is valid or not.
    $emailValidationDTO = $client->validate('[email protected]');

    /* Output: 
    {
      +"status": "success"
      +"result": "invalid"
      +"flags": array:4 [
        0 => "free_email_host"
        1 => "has_dns"
        2 => "has_dns_mx"
        3 => "smtp_connectable"
      ]
      +"suggested_correction": ""
      +"execution_time": 309
    }
    */

    // Build the client.
    $client = NeverBounceClient::build();

    // Create the job over at NeverBounce.
    $jobId = $client->bulkVerify(['[email protected]', '[email protected]']);
    
    // Periodicly check the job for results.
    for ($a = 0; $a < 30; ++$a) {
        $bulkValidationDTO = $client->checkJob($jobId);
        if (!$bulkValidationDTO) {
            sleep(1);
        }
        
        break;
    }
    
    /** Output:
    BulkValidationDTO [
        'status'           => 'success',
        'id'               => 2917483,
        'job_status'       => 'complete',
        'filename'         => 'bulk-1559703280.csv',
        'created_at'       => Carbon: '2019-06-04 22:54:41',
        'started_at'       => Carbon: '2019-06-04 22:54:42',
        'finished_at'      => Carbon: '2019-06-04 22:54:47',
        'total'            => ListStatsDTO [
            'records'    => 7,
            'billable'   => 5,
            'processed'  => 7,
            'valid'      => 3,
            'invalid'    => 3,
            'catchall'   => 1,
            'disposable' => 0,
            'unknown'    => 0,
            'duplicates' => 1,
            'bad_syntax' => 1,
        ],
        'bounce_estimate'  => 28.571428571429,
        'percent_complete' => 100,
        'execution_time'   => 12,
    ]
     */