PHPackages                             martian/spammailchecker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. martian/spammailchecker

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

martian/spammailchecker
=======================

A laravel package that protect users from entering non-existing/spam email addresses.

2.1.0(10mo ago)422.0k7MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Jan 26Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/hendurhance/laravel-spam-email)[ Packagist](https://packagist.org/packages/martian/spammailchecker)[ Docs](https://github.com/hendurhance/laravel-spam-email)[ Fund](https://www.buymeacoffee.com/hendurhance)[ GitHub Sponsors](https://github.com/hendurhance)[ RSS](/packages/martian-spammailchecker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (11)Used By (0)

Laravel SpamMailChecker
=======================

[](#laravel-spammailchecker)

[![Latest Stable Version](https://camo.githubusercontent.com/391ab3ea8920d5e9261402ea82437d3bd11e5a59b85536c0ca09d0bad6fa3ea3/687474703a2f2f706f7365722e707567782e6f72672f6d61727469616e2f7370616d6d61696c636865636b65722f76)](https://packagist.org/packages/martian/spammailchecker) [![Total Downloads](https://camo.githubusercontent.com/e883f2da5061540e4e73cbe7f2be8897379e529208ffc4bad4cdc7b7db0caa21/687474703a2f2f706f7365722e707567782e6f72672f6d61727469616e2f7370616d6d61696c636865636b65722f646f776e6c6f616473)](https://packagist.org/packages/martian/spammailchecker) [![Latest Unstable Version](https://camo.githubusercontent.com/bfa51dc2d0ed256e36f2045c6dcb310457a50c6477351a6657f6eb5d76cb3f54/687474703a2f2f706f7365722e707567782e6f72672f6d61727469616e2f7370616d6d61696c636865636b65722f762f756e737461626c65)](https://packagist.org/packages/martian/spammailchecker) [![License](https://camo.githubusercontent.com/f0b86d63b27c417e85867bd6d1648b587d09c3d5057fff31f32975e7bf211518/687474703a2f2f706f7365722e707567782e6f72672f6d61727469616e2f7370616d6d61696c636865636b65722f6c6963656e7365)](https://packagist.org/packages/martian/spammailchecker) [![PHP Version Require](https://camo.githubusercontent.com/0528e154c9a9bacd2cac009a0f2e6b0120ca131ef286de3223ca1d423843d573/687474703a2f2f706f7365722e707567782e6f72672f6d61727469616e2f7370616d6d61696c636865636b65722f726571756972652f706870)](https://packagist.org/packages/martian/spammailchecker)[![Made in Nigeria](https://camo.githubusercontent.com/6f2b7d02df82f57e88110a2cc9439f3da778466aec9a2ee4987f2b6768482f06/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d616465253230696e2d6e6967657269612d3030383735312e7376673f7374796c653d666c61742d737175617265)](https://github.com/acekyd/made-in-nigeria)

A powerful Laravel package designed to effortlessly validate email addresses against various spam mail providers using a diverse range of drivers. Seamlessly integrated with Laravel's validation system, this package offers comprehensive support for validating email inputs in forms and RESTful APIs

Supported Email Validation Services
-----------------------------------

[](#supported-email-validation-services)

ServiceDescriptionsDriverDocumentationSupported**Local**A local text list of spam email domains.*local*[Read More](/resources/config/emails.txt)✅ Yes**Remote**Using PHP In-built functions `getmxrr()`, `checkdnsrr()`. `fsockopen()` to validate email domain*remote*[Read More](https://www.php.net/manual/en/function.getmxrr.php)✅ Yes**AbstractApi**Using Abstract's suite of API to validate email domains*abstractapi*[Read More](https://www.abstractapi.com/email-verification-validation-api)✅ Yes**QuickEmailVerification**A reliable, accurate, affordable, and advanced email verification service*quickemailverification*[Read More](https://quickemailverification.com/)✅ Yes**Verifalia**A web-based email validation service which allows to upload and validate lists of email addresses with ease*verifalia*[Read More](https://verifalia.com/)✅ Yes**SendGrid**A cloud-based SMTP provider that allows you to validate email addresses before you send.*sendgrid*[Read More](https://sendgrid.com/solutions/email-api/email-address-validation-api/)✅ Yes> **NOTE:** More services will be added soon. (You can also contribute to this project by adding more services - ZeroBounce, Mailboxlayer, EmailListVerify, Emailable, etc)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require martian/spammailchecker
```

```
Martian\SpamMailChecker\SpamMailCheckerServiceProvider::class,
```

- If you are going to be using the facade, you'll need to register it as well. Open `config/app.php` and add the following line to the `aliases` array:

```
'SpamMailChecker' => Martian\SpamMailChecker\Facades\SpamMailChecker::class,
```

Publish Configuration File
--------------------------

[](#publish-configuration-file)

Publish the configuration file using the following command:

```
php artisan vendor:publish --provider="Martian\SpamMailChecker\Providers\SpamMailCheckerServiceProvider"
```

Configuration
-------------

[](#configuration)

The configuration file is located at `config/laravel-spammail-checker.php`. You may configure the package to use any of the supported drivers. The default driver is `local` which uses a local text list of spam email domains.

#### Local Driver Configuration

[](#local-driver-configuration)

- In order to use `local`as your driver of choice, you need to set the `default` key in the `config/laravel-spammail-checker.php` configuration file to `local`:

    ```
        'default' => 'local',
    ```
- Or you can set the `SPAM_MAIL_CHECKER_DEFAULT_DRIVER` environment variable to `local` in your `.env` file.

    ```
        SPAM_MAIL_CHECKER_DEFAULT_DRIVER=local
    ```
- The local driver uses a local text list of spam email domains. The file is located at `resources/config/emails.txt`. You can include more domains by adding them to the `blacklist` array or exclude domains by adding them to the `whitelist` array.

    ```
        'drivers' => [
            'local' => [
                ...
                'whitelist' => [
                    // Add domains you want the local driver to ignore here
                    'gmail.com',
                    'yahoo.com',
                ],
                'blacklist' => [
                    // Add domains you want the local driver to validate against here
                    'mailinator.com',
                    'spam.com',
                ],
            ]
        ]
    ```
- Clear the config and cache using the following commands after making changes to the configuration file:

    ```
        php artisan optimize:clear
    ```

> **NOTE:** The local driver is case-insensitive. So, you don't need to worry about the case of the email domain.

#### Remote Driver Configuration

[](#remote-driver-configuration)

- In order to use `remote` as your driver of choice, you need to set the `default` key in the `config/laravel-spammail-checker.php` configuration file to `remote`:

    ```
        'driver' => 'remote',
    ```
- Or you can set the `SPAM_MAIL_CHECKER_DEFAULT_DRIVER` environment variable to `remote` in your `.env` file.

    ```
        SPAM_MAIL_CHECKER_DEFAULT_DRIVER=remote
    ```
- The remote driver uses PHP In-built functions `getmxrr()`, `checkdnsrr()`. `fsockopen()` to validate email domain. You can configure the remote driver on whether to check for MX - `getmxrr()`, DNS - `checkdnsrr()`, and SMTP -`fsockopen` or validate email domain. You can also configure the timeout value in seconds.

    ```
        'drivers' => [
            ...
            'remote' => [
                ...
                'check_dns' => true, // When set to true, it will check for DNS
                'check_smtp' => false, // When set to true, it will check for SMTP
                'check_mx' => false, // When set to true, it will check for MX record
                'timeout' => 60 * 5, // 5 minutes
            ]
        ]
    ```

#### AbstractApi Driver Configuration

[](#abstractapi-driver-configuration)

- In order to use `abstractapi` as your driver of choice, you need to set the `default` key in the `config/laravel-spammail-checker.php` configuration file to `abstractapi`:

    ```
        'default' => 'abstractapi',
    ```
- Or you can set the `SPAM_MAIL_CHECKER_DEFAULT_DRIVER` environment variable to `abstractapi` in your `.env` file.

    ```
        SPAM_MAIL_CHECKER_DEFAULT_DRIVER=abstractapi
    ```
- Add your `ABSTRACTAPI_API_KEY` AbstractAPI key you got from [here](https://app.abstractapi.com/dashboard) to your `env` file.

    ```
    ABSTRACTAPI_API_KEY=abstractapi_api_key

    ```
- You can configure the `score` to determine the threshold for a valid email address. The score ranges from 0 to 1. The higher the score, the more likely the email address is valid. You can also accept disposable email addresses by setting `accept_disposable` to `true`.

    ```
        'drivers' => [
            ...
            'abstractapi' => [
                ...
                'score' => 0.5, // 0.5 is the default score
                'accept_disposable_email' => true // When set to true, it will accept disposable email addresses
            ]
        ]
    ```

#### QuickEmailVerification Driver Configuration

[](#quickemailverification-driver-configuration)

- In order to use `quickemailverification` as your driver of choice, you need to set the `default` key in the `config/laravel-spammail-checker.php` configuration file to `quickemailverification`:

    ```
        'default' => 'quickemailverification',
    ```
- Or you can set the `SPAM_MAIL_CHECKER_DEFAULT_DRIVER` environment variable to `quickemailverification` in your `.env` file.

    ```
        SPAM_MAIL_CHECKER_DEFAULT_DRIVER=quickemailverification
    ```
- Add your `QUICKEMAILVERIFICATION_API_KEY` QuickEmailVerification key you got from [here](https://quickemailverification.com/dashboard) to your `env` file.

    ```
    QUICKEMAILVERIFICATION_API_KEY=quickemailverification_api_key
    ```
- You can configure the driver to accept disposable email addresses by setting `accept_disposable` to `true`.

    ```
        'drivers' => [
            ...
            'quickemailverification' => [
                ...
                'accept_disposable' => true, // When set to true, it will accept disposable email addresses
            ]
        ]
    ```

#### Verifalia Driver Configuration

[](#verifalia-driver-configuration)

- In order to use `verifalia` as your driver of choice, you need to set the `default` key in the `config/laravel-spammail-checker.php` configuration file to `verifalia`:

    ```
        'default' => 'verifalia',
    ```
- Or you can set the `SPAM_MAIL_CHECKER_DEFAULT_DRIVER` environment variable to `verifalia` in your `.env` file.

    ```
        SPAM_MAIL_CHECKER_DEFAULT_DRIVER=verifalia
    ```
- In order to use verifalia service, you need to set login credentials in your `env` file. You can get your credentials from after you create a user [here](https://verifalia.com/client-area#/users).

    ```
    VERIFALIA_USERNAME=verifalia_username
    VERIFALIA_PASSWORD=verifalia_password
    ```
- You can configure the driver to accept disposable email addresses by setting `accept_disposable` to `true`.

    ```
        'drivers' => [
            ...
            'verifalia' => [
                ...
                'accept_disposable' => true, // When set to true, it will accept disposable email addresses
            ]
        ]
    ```

> **NOTE:** A user on verifalia needs to be granted permission to use the API. You can do this by going [here](https://verifalia.com/client-area#/users) and clicking on the edit user you want to grant permission to. Then click on the `Permissions` tab and check the appropriate permissions on `Email validations` section.

#### SendGrid Driver Configuration

[](#sendgrid-driver-configuration)

- In order to use `sendgrid` as your driver of choice, you need to set the `default` key in the `config/laravel-spammail-checker.php` configuration file to `sendgrid`:

    ```
        'default' => 'sendgrid',
    ```
- Or you can set the `SPAM_MAIL_CHECKER_DEFAULT_DRIVER` environment variable to `sendgrid` in your `.env` file.

    ```
        SPAM_MAIL_CHECKER_DEFAULT_DRIVER=sendgrid
    ```
- Add your `SENDGRID_API_KEY` Sendgrid key you got from [here](https://app.sendgrid.com/settings/api_keys) to your `env` file.

    ```
      SENDGRID_API_KEY=sendgrid_api_key
    ```
- You can configure the driver to accept disposable email addresses by setting `accept_disposable` to `true`. Score can also be configured to determine the threshold for a valid email address. The score ranges from 0 to 1. The higher the score, the more likely the email address is valid. Source can also be configured to determine the source of the email address. The source can be `signup` or `contact`.

    ```
        'drivers' => [
            ...
            'sendgrid' => [
                ...
                'score' => 0.5, // 0.5 is the default score
                'accept_disposable' => true, // When set to true, it will accept disposable email addresses
                'source' => 'signup' // The source is signup by default
            ]
        ]
    ```

Usage
-----

[](#usage)

In order to use the package, you need to call the `spammail` validation rule in your validation rules. You can also change the rule name to whatever you want in the `config/laravel-spammail-checker.php` configuration file under the `rule` key, likewise the error message under the `error_message` key.

```
/**
 * Get a validator for an incoming registration request.
 *
 * @param  array  $data
 * @return \Illuminate\Contracts\Validation\Validator
 */
protected function validator(array $data)
{
    return Validator::make($data, [
        'email' => 'required|spammail|max:255',
    ]);
}
```

Or make use of `spammail` in your Requests file like this:

```
 /**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [
        'email' => 'required|spammail|max:255',
    ];
}
```

#### Adding Custom Error Message

[](#adding-custom-error-message)

A custom error message can be added to the `spammail` validation rule.

```
    'email.spammail' => 'This email address is invalid.', // Custom error message
```

Or you can change the error message in the `config/laravel-spammail-checker.php` configuration file under the `error_message` key.

```
    'error_message' => 'This email address is invalid.', // Custom error message
```

#### Using Classes Directly

[](#using-classes-directly)

You can also use the classes directly without using the `spammail` validation rule. This is useful when you want to use the package in your own custom validation rule or your own custom class.

```
use Martian\SpamMailChecker\SpamMailChecker;

public function checkEmail($email)
{
    $spamMailChecker = new SpamMailChecker();
    $spamMailChecker->validate($email);
}
```

#### Using Facade

[](#using-facade)

You can also use the `SpamMailChecker` class directly without instantiating it.

```
use Martian\SpamMailChecker\Facades\SpamMailChecker;

public function checkEmail($email)
{
    SpamMailChecker::validate($email);
}
```

#### Using Each Driver Individually

[](#using-each-driver-individually)

You can also use each driver individually without using the `spammail` validation rule. This is useful when a certain driver is needed in a particular situation.

##### Using VerifaliaDriver

[](#using-verifaliadriver)

```
use Martian\SpamMailChecker\Drivers\VerifaliaDriver;

public function checkEmail($email)
{
    $verifaliaDriver = new VerifaliaDriver();
    $verifaliaDriver->validate($email);
}
```

##### Using SendGridDriver

[](#using-sendgriddriver)

```
use Martian\SpamMailChecker\Drivers\SendGridDriver;

public function checkEmail($email)
{
    $sendGridDriver = new SendGridDriver();
    $sendGridDriver->validate($email);
}
```

##### Using AbstractApiDriver

[](#using-abstractapidriver)

```
use Martian\SpamMailChecker\Drivers\AbstractApiDriver;

public function checkEmail($email)
{
    $abstractApiDriver = new AbstractApiDriver();
    $abstractApiDriver->validate($email);
}
```

##### Using RemoteDriver

[](#using-remotedriver)

```
use Martian\SpamMailChecker\Drivers\RemoteDriver;

public function checkEmail($email)
{
    $remoteDriver = new RemoteDriver();
    $remoteDriver->validate($email);
}
```

##### Using LocalDriver

[](#using-localdriver)

```
use Martian\SpamMailChecker\Drivers\LocalDriver;

public function checkEmail($email)
{
    $localDriver = new LocalDriver();
    $localDriver->validate($email);
}
```

##### Using QuickEmailVerificationDriver

[](#using-quickemailverificationdriver)

```
use Martian\SpamMailChecker\Drivers\QuickEmailVerificationDriver;

public function checkEmail($email)
{
    $quickEmailVerificationDriver = new QuickEmailVerificationDriver();
    $quickEmailVerificationDriver->validate($email);
}
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please feel free to fork this project and make a pull request. For more information check [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Josiah Endurance](https://github.com/hendurhance)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance54

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 78.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~180 days

Recently: every ~199 days

Total

8

Last Release

307d ago

Major Versions

1.4 → 2.0.02023-08-02

PHP version history (3 changes)1.0.0PHP ^7.4|^8.0

2.0.0PHP ^7.2|^7.4|^8.0

2.1.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1a2a17381645674b6254cd41641c17218986676b167821631faec6d0fd7f664?d=identicon)[hendurhance](/maintainers/hendurhance)

---

Top Contributors

[![hendurhance](https://avatars.githubusercontent.com/u/50846992?v=4)](https://github.com/hendurhance "hendurhance (45 commits)")[![dsbilling](https://avatars.githubusercontent.com/u/9788214?v=4)](https://github.com/dsbilling "dsbilling (11 commits)")[![yoeriboven](https://avatars.githubusercontent.com/u/4047804?v=4)](https://github.com/yoeriboven "yoeriboven (1 commits)")

---

Tags

composeremailemail-validationemail-validatoremail-validator-apilaravellibrarypackagepackagistphpphp-libraryphp-sdsdkspam-detectionspam-filteringvalidationvalidatorphplaravelvalidationpackagesecurityemailspamgithubcheckerspamfreemartianspammailchecker

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/martian-spammailchecker/health.svg)

```
[![Health](https://phpackages.com/badges/martian-spammailchecker/health.svg)](https://phpackages.com/packages/martian-spammailchecker)
```

###  Alternatives

[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[misma/laravel-mailpeek

MailPeek provides a simple local inbox right in your browser to enable you preview emails being sent from your application.

222.1k](/packages/misma-laravel-mailpeek)[ashallendesign/laravel-mailboxlayer

A lightweight Laravel package for validating emails using the Mailbox Layer API.

762.0k](/packages/ashallendesign-laravel-mailboxlayer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
