AnthonyPorthouse / laravel-neverbounce by groundsix

Laravel style wrapper for https://github.com/NeverBounce/NeverBounceAPI-PHP
5,285
2
5
Package Data
Maintainer Username: groundsix
Maintainer Contact: james.fenwick@groundsix.com (James Fenwick)
Package Create Date: 2016-08-19
Package Last Update: 2016-11-09
Home Page:
Language: PHP
License: proprietary
Last Refreshed: 2024-04-17 15:01:18
Package Statistics
Total Downloads: 5,285
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 2
Total Watchers: 5
Total Forks: 1
Total Open Issues: 0

Check an email address exists

Latest Version on Packagist

This package allows email to be easily checked against https://neverbounce.com/.

Once installed you can do stuff like this:

$this->validate($request, [
  'email' => 'neverbounce',
]);

or

NeverBounce::valid($email);

Install

You can install the package via composer:

$ composer require ground/laravel-neverbounce

This service provider must be installed.

// config/app.php
'providers' => [
    ...
    Groundsix\Neverbounce\NeverBounceServiceProvider::class,
];

'aliases' => [
    ...
    'NeverBounce' => Groundsix\Neverbounce\Facades\NeverBounce::class,
];

You can publish the config-file with:

php artisan vendor:publish --provider="Groundsix\Neverbounce\NeverBounceServiceProvider" --tag="config"

And your Neverbounce api details should be added to .env:

NEVERBOUNCE_USERNAME=<username>
NEVERBOUNCE_SECRET_KEY=<secret key>

Usage

This package registers the Neverbounce\API\NB_Single into the application. But for conveniance provides a facade and a validator to simplify checking an email address.

Validator

class AuthController extends Controller
{
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'email' => 'required|email|max:255|unique:users|neverbounce',
            'password' => 'required|min:6|confirmed',
        ]);
    }
}

Facade

...
use NeverBounce;

class AuthController extends Controller
{
    protected function storeEmail(Request $request)
    {
        if(NeverBounce::valid($request->get('email'))){
          //do something
        }
    }
}

NB_Single

Or you can access NB_Single directly. See https://github.com/NeverBounce/NeverBounceAPI-PHP#single for more details.

...
use NeverBounce\API\NB_Single;

class AuthController extends Controller
{
    protected function storeEmail(Request $request)
    {
        if(app(NB_Single::class)->valid($request->get('email'))->is(NB_Single::GOOD)){
          //do something
        }
    }
}