PHPackages                             sagautam5/laravel-email-blocker - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. sagautam5/laravel-email-blocker

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

sagautam5/laravel-email-blocker
===============================

Rule Based email blocking on laravel application

v1.0.0(6mo ago)28MITPHPCI passing

Since Dec 28Pushed 6mo agoCompare

[ Source](https://github.com/sagautam5/laravel-email-blocker)[ Packagist](https://packagist.org/packages/sagautam5/laravel-email-blocker)[ RSS](/packages/sagautam5-laravel-email-blocker/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Laravel Email Blocker
---------------------

[](#laravel-email-blocker)

[![Build](https://github.com/sagautam5/laravel-email-blocker/workflows/CI/badge.svg)](https://github.com/sagautam5/laravel-email-blocker/workflows/CI/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/c698b9a7dc93ea73069b0ac385ae68114d32499d2c584ad1324451863f3b49ee/68747470733a2f2f706f7365722e707567782e6f72672f736167617574616d352f6c61726176656c2d656d61696c2d626c6f636b65722f76)](//packagist.org/packages/sagautam5/laravel-email-blocker)[![Total Downloads](https://camo.githubusercontent.com/f804a9a5eae76367ad5fca5a0bfa8fd2abcbed5624a07b5998052270bfe22f07/68747470733a2f2f706f7365722e707567782e6f72672f736167617574616d352f6c61726176656c2d656d61696c2d626c6f636b65722f646f776e6c6f616473)](//packagist.org/packages/sagautam5/laravel-email-blocker)[![Issues](https://camo.githubusercontent.com/9bf343889e1114aab4bb1a74a013ae78103ea2b1109babb8744db008936b1f51/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736167617574616d352f6c61726176656c2d656d61696c2d626c6f636b6572)](https://github.com/sagautam5/laravel-email-blocker/issues) [![Stars](https://camo.githubusercontent.com/73de4536a3a9ea212bc6e85694a8a7c064d17b5677a93c3a6962f31a590f4aed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f736167617574616d352f6c61726176656c2d656d61696c2d626c6f636b6572)](https://github.com/sagautam5/laravel-email-blocker/stargazers)[![License](https://camo.githubusercontent.com/812cb1e040d5d72c8a0605963460a6f10173b12c45e865fea85de46142e1535c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736167617574616d352f6c61726176656c2d656d61696c2d626c6f636b6572)](https://github.com/sagautam5/laravel-email-blocker/blob/master/LICENSE)[![Forks](https://camo.githubusercontent.com/adbef600cb157998b073e9563660a218650d8261854d24e65b6902c95db27000/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f736167617574616d352f6c61726176656c2d656d61696c2d626c6f636b6572)](https://github.com/sagautam5/laravel-email-blocker/network/members)[![Twitter](https://camo.githubusercontent.com/7bc55f033743d203ebf392de9e9b468ea1a96e8657b04bb97be363cc97325228/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c3f75726c3d68747470732533412532462532466769746875622e636f6d253246736167617574616d352532466c61726176656c2d656d61696c2d626c6f636b6572)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fsagautam5%2Flaravel-email-blocker)

🚀 Introduction
--------------

[](#-introduction)

Laravel Email Blocker is a lightweight and extensible package that allows you to control, block, log, and analyze outgoing emails using configurable, rule-based logic.

It is especially useful for:

- 🧪 Local, testing, and staging environments
- 🏢 Multi-tenant or enterprise systems
- 📜 Compliance-sensitive applications
- 🚨 Preventing accidental emails to real users

The package integrates seamlessly with Laravel’s mail system and introduces minimal overhead.

📑 Table of Contents
-------------------

[](#-table-of-contents)

- [Introduction](#-introduction)
- [Features](#-features)
- [Requirements](#-requirements)
- [Installation](#-installation)
- [Configuration](#-configuration)
    - [Default Configuration](#default-configuration)
    - [Validate Configuration](#validate-configuration)
- [Usage Guide](#-usage-guide)
    - [Disable Email Blocking Completely](#disable-email-blocking-completely)
    - [Disable Specific Rules](#disable-specific-rules)
    - [Built-in Blocking Rules](#-built-in-blocking-rules)
        - [Global Block](#1%EF%B8%8F%E2%83%A3-global-block)
        - [Environment Block](#2%EF%B8%8F%E2%83%A3-environment-block)
        - [Domain Block](#3%EF%B8%8F%E2%83%A3-domain-block)
        - [Mailable Block](#4%EF%B8%8F%E2%83%A3-mailable-block)
        - [Time Window Block](#5%EF%B8%8F%E2%83%A3-time-window-block)
        - [Email Block](#6%EF%B8%8F%E2%83%A3-email-block)
- [Insights &amp; Metrics](#-insights--metrics)
    - [Available Metrics](#available-metrics)
    - [Common Filters](#common-filters)
    - [Example Usage](#example-usage)
    - [Example Output](#example-output)
- [Customization](#-customization)
    - [Example Custom Rule](#example-custom-rule)
    - [Example Custom Metric](#example-custom-metric)
        - [Usage](#usage)
        - [Output](#output)
- [Security](#-security)
- [Contributing](#-contributing)
- [Code of Conduct](#%EF%B8%8F-code-of-conduct)
- [Credits](#-credits)
- [Support](#-support)
- [License](#-license)

---

✨ Features
----------

[](#-features)

- 🚫 Rule-based email blocking
- 🧩 Pluggable &amp; extensible rule architecture
- 📝 Persistent logging of blocked emails
- 📊 Built-in insights &amp; metrics
- 🧪 Pest PHP–friendly test setup
- ⚙️ Zero changes required to existing mail code

---

📋 Requirements
--------------

[](#-requirements)

- PHP **8.2** or higher
- Laravel **11.x** or higher

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require sagautam5/laravel-email-blocker
```

The package supports Laravel auto-discovery.

🔧 Configuration
---------------

[](#-configuration)

Publish Configuration File

```
php artisan vendor:publish --provider="Sagautam5\EmailBlocker\EmailBlockerServiceProvider --tag="config"
```

This will create:

```
config/email-blocker.php
```

### Default Configuration

[](#default-configuration)

```
