Handy email blacklist management for Laravel.
You can install this package via composer using this command:
composer require hivokas/laravel-email-blacklist
The package will automatically register itself.
You can publish the migration with:
php artisan vendor:publish --provider="Hivokas\EmailBlacklist\Providers\EmailBlacklistServiceProvider" --tag="migrations"
After the migration has been published you can create the table for blacklisted emails by running the migrations:
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Hivokas\EmailBlacklist\Providers\EmailBlacklistServiceProvider" --tag="config"
This is the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| Table Name For Email Blacklist Storing
|--------------------------------------------------------------------------
*/
'table_name' => 'blacklisted_emails',
/*
|--------------------------------------------------------------------------
| BlacklistedEmail Model
|--------------------------------------------------------------------------
*/
'model' => \Hivokas\EmailBlacklist\Models\BlacklistedEmail::class,
];
use Hivokas\EmailBlacklist\Facades\EmailBlacklist;
EmailBlacklist::add('[email protected]');
EmailBlacklist::count(); // 1
EmailBlacklist::all(); // ['[email protected]']
EmailBlacklist::exists('[email protected]'); // true
EmailBlacklist::remove('[email protected]');
EmailBlacklist::exists('[email protected]'); // false
EmailBlacklist::count(); // 0
Returns all blacklisted emails.
Returns amount of blacklisted emails.
Returns true
if email is blacklisted and vice versa.
Adds email to the blacklist.
Removes email from the blacklist.
Throws an InvalidArgumentException
is email is invalid.
You can run the tests with:
composer test