Giter Site home page Giter Site logo

veeqtoh / laravel-active-email Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 78 KB

A Laravel package providing validation rule against disposable email addresses.

License: MIT License

PHP 100.00%
disposable-domains disposable-email disposable-email-domains disposable-emails laravel mail

laravel-active-email's Introduction

laravel-active-email

Latest Version on Packagist Total Downloads PHP from Packagist GitHub license

Table of Contents

Overview

This package provides a library of disposable domains and adds a validator to Laravel apps to check that a given email address isn't coming from a disposable email service such as Mailinator, Guerillamail, Tempmail considering all their possible wildcards.

Key Features

  • You can add your own preferred domains to the black list.
  • You can white list a domain to bye pass the blacklist. This can be useful in development environment.
  • With strict mode, you can control the strictness of the validator, thereby allowing or preventing domains that are not necessarily disposable, but have been classified as disposable.
  • Case-aware.
  • Wildcard-aware.

Installation

Requirements

The package has been developed and tested to work with the following minimum requirements:

  • PHP 8.x
  • Laravel 10.x, 11.x

Install the Package

You can install the package via Composer. The service provider is discovered automatically.

composer require veeqtoh/laravel-active-email

Publish the Config

You can then publish the package's config file and update it as you'd prefer:

php artisan vendor:publish --provider="Veeqtoh\ActiveEmail\Providers\ActiveEmailProvider"

Usage

Validator Approach

Add the notblacklisted validator to your email validation rules array (or string) to ensure that the domain for a given email address is not blacklisted. I'd recommend you add it after the email validator to make sure a valid email is passed through:

'emailField' => 'email|notblacklisted',

or

'emailField' => ['email', 'notblacklisted'],

Class Approach

Instantiate the NotBlackListedEmail Class as part of your email validation rules array to ensure that the domain for a given email address is not blacklisted. Again, I'd recommend you add it after the email validator to make sure a valid email is passed through:

use Veeqtoh\ActiveEmail\Rules\NotBlackListedEmail;

'emailField' => ['email', new NotBlackListedEmail()],

Customization

The package is highly customizable from the config file with the following features:

Strict Mode

This value determines the strictness level of this feature. when set to true, domains in the grey list are also blacklisted.

It is turned on by default, but can be set in your .env file as follows:

DISPOSABLE_EMAIL_STRICT_MODE=true,

Black List

This is a list of base domains with or without the TLD that are blacklisted by default. Add a domain to this list to blacklist it.

Grey List

This is a list of base domains with or without the TLD that aren't blacklisted by default except when in strict mode. Add a domain to this list to whitelist it when the feature is not set to strict mode. Ensure that the domain is not on the black list.

White List

This is a list of base domains with or without the TLD that are blacklisted by default but you want them to be bye passed.

To Do

There's always something that can be done to improve this package. I'd keep updating this list as I think of them.

  • Crawl the web to grab an updated list of disposable domains.
  • Maybe setup a schedule for it..

Testing

To run the package's unit tests, run the following command:

vendor/bin/pest

Security

If you find any security related issues, please contact me directly at [email protected] to report it.

Contribution

If you wish to make any changes or improvements to the package, feel free to make a pull request.

Note: A contribution guide will be added soon.

Changelog

Check the CHANGELOG to get more information about the latest changes.

Upgrading

Check the UPGRADE guide to get more information on how to update this library to newer versions.

License

The MIT License (MIT). Please see License File for more information.

Support Me

If you've found this package useful, please consider sponsoring this project. It will encourage me to keep maintaining it.

laravel-active-email's People

Contributors

veeqtoh avatar

Stargazers

Mohammed Samgan Khan avatar  avatar  avatar Sai Chand Reddy Kamana avatar  avatar Ian Hawes avatar Arthur K. Kyagulanyi  avatar Karol Dąbrowski avatar guanguans avatar  avatar  avatar Cr Sanjay Singh avatar Mobolaji Fakunle avatar Victor Ukam avatar

Watchers

 avatar

Forkers

crsanjaysingh

laravel-active-email's Issues

Readme incorrectly says Fastmail is blocked.

The blocklist contains Fast-mail, with a hyphen, not Fastmail (without the hyphen). The Overview section of the Readme incorrectly says Fastmail, without a hyphen, is black listed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.