PHPackages                             fakeeh/laravel-secure-email - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. fakeeh/laravel-secure-email

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

fakeeh/laravel-secure-email
===========================

Laravel package to monitor and handle AWS SES email complaints, bounces, and deliveries via SNS notifications - Laravel 13 compatible

2.0.0(2mo ago)0256MITPHPPHP ^8.3CI passing

Since Nov 24Pushed 2mo agoCompare

[ Source](https://github.com/fakeeh/laravel-secure-email)[ Packagist](https://packagist.org/packages/fakeeh/laravel-secure-email)[ RSS](/packages/fakeeh-laravel-secure-email/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (14)Versions (3)Used By (0)

Laravel SES Monitor
===================

[](#laravel-ses-monitor)

[![Latest Version](https://camo.githubusercontent.com/3701f0c290d1448dc51eed17b08e41b4d72aefca8d634c85ef51941d0c481c0f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66616b6565682f6c61726176656c2d7365637572652d656d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fakeeh/laravel-secure-email)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/141c328f9c928bde03c5caf869363ca53e65ed960fda47e7d508fd21b7391284/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f66616b6565682f6c61726176656c2d7365637572652d656d61696c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fakeeh/laravel-secure-email)

A production-ready Laravel package to monitor and handle AWS SES email complaints, bounces, and deliveries via SNS notifications. Automatically prevents sending emails to addresses that have bounced or complained.

**Compatible with Laravel 13** (PHP 8.3+)

Features
--------

[](#features)

- ✅ **Automatic Email Blocking**: Prevents sending to emails with bounces/complaints
- ✅ **SNS Webhook Handling**: Processes bounce, complaint, and delivery notifications
- ✅ **Auto Subscription Confirmation**: Automatically confirms SNS subscriptions
- ✅ **Flexible Configuration**: Customize rules for bounces and complaints
- ✅ **Event System**: Fire events for bounces, complaints, and deliveries
- ✅ **Database Storage**: Store all notifications for analysis
- ✅ **Permanent Bounce Protection**: Block emails with permanent bounces immediately
- ✅ **Subject-based Filtering**: Count bounces/complaints by email subject
- ✅ **Time-based Rules**: Set time windows for counting notifications
- ✅ **Laravel 13 Compatible**: Built for Laravel 13 with PHP 8.3+

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 13.x
- AWS SES account with SNS configured

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

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require fakeeh/laravel-secure-email
```

### Step 2: Publish Configuration and Migrations

[](#step-2-publish-configuration-and-migrations)

```
# Publish config file
php artisan vendor:publish --tag=secure-email-config

# Publish migrations (optional, auto-loaded by default)
php artisan vendor:publish --tag=secure-email-migrations

# Run migrations
php artisan migrate
```

This will create two tables:

- `sns_subscriptions` - Stores SNS subscription confirmation requests
- `ses_notifications` - Stores bounce, complaint, and delivery notifications

### Step 3: Configure Your Environment

[](#step-3-configure-your-environment)

Add these variables to your `.env` file:

```
# Enable/disable the package
SES_MONITOR_ENABLED=true

# Auto-confirm SNS subscriptions
SES_MONITOR_AUTO_CONFIRM=true

# Validate SNS message signatures
SES_MONITOR_VALIDATE_SNS=true

# Route configuration
SES_MONITOR_ROUTE_PREFIX=aws/sns/ses
SES_MONITOR_BOUNCES_ROUTE=bounces
SES_MONITOR_COMPLAINTS_ROUTE=complaints
SES_MONITOR_DELIVERIES_ROUTE=deliveries

# Bounce rules
SES_MONITOR_CHECK_BOUNCES=true
SES_MONITOR_MAX_BOUNCES=3
SES_MONITOR_CHECK_BOUNCES_BY_SUBJECT=false
SES_MONITOR_BLOCK_PERMANENT_BOUNCES=true
SES_MONITOR_BOUNCE_DAYS=30

# Complaint rules
SES_MONITOR_CHECK_COMPLAINTS=true
SES_MONITOR_MAX_COMPLAINTS=1
SES_MONITOR_CHECK_COMPLAINTS_BY_SUBJECT=true
SES_MONITOR_COMPLAINT_DAYS=0
```

AWS Configuration
-----------------

[](#aws-configuration)

### Step 1: Create SNS Topics

[](#step-1-create-sns-topics)

In your AWS SNS console, create three HTTP/HTTPS topics:

1. **Bounces Topic**: `https://yourdomain.com/aws/sns/ses/bounces`
2. **Complaints Topic**: `https://yourdomain.com/aws/sns/ses/complaints`
3. **Deliveries Topic**: `https://yourdomain.com/aws/sns/ses/deliveries`

### Step 2: Configure SES to Send Notifications

[](#step-2-configure-ses-to-send-notifications)

1. Go to AWS SES Console
2. Select your verified domain or email
3. Click "Notifications" → "Edit Configuration"
4. Set the SNS topics:
    - **Bounces**: Select your bounces SNS topic
    - **Complaints**: Select your complaints SNS topic
    - **Deliveries**: Select your deliveries SNS topic (optional)

### Step 3: Subscription Confirmation

[](#step-3-subscription-confirmation)

The package will automatically confirm subscriptions when auto-confirm is enabled. If not, you can:

```
# View unconfirmed subscriptions
php artisan secure-email:subscribe-urls

# Or manually visit the SubscribeURL in your database
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Once installed and configured, the package works automatically:

1. **Incoming Notifications**: AWS SNS sends notifications to your endpoints
2. **Storage**: Notifications are stored in the `ses_notifications` table
3. **Email Interception**: Before sending any email, the package checks if the recipient should be blocked
4. **Blocking**: Emails to blocked addresses are prevented from sending

### Checking if an Email is Blocked

[](#checking-if-an-email-is-blocked)

```
use Fakeeh\SecureEmail\Models\SesNotification;

// Check for permanent bounces
if (SesNotification::hasPermanentBounce('[email protected]')) {
    // Don't send email
}

// Count bounces for an email
$bounceCount = SesNotification::countBouncesForEmail('[email protected]');

// Count bounces with subject filter
$bounceCount = SesNotification::countBouncesForEmail(
    '[email protected]',
    'Weekly Newsletter',
    30 // days
);

// Count complaints
$complaintCount = SesNotification::countComplaintsForEmail('[email protected]');
```

### Querying Notifications

[](#querying-notifications)

```
use Fakeeh\SecureEmail\Models\SesNotification;

// Get all bounces
$bounces = SesNotification::bounces()->get();

// Get permanent bounces
$permanentBounces = SesNotification::permanentBounces()->get();

// Get complaints for a specific email
$complaints = SesNotification::complaints()
    ->forEmail('[email protected]')
    ->get();

// Get recent notifications (last 30 days)
$recent = SesNotification::recent(30)->get();

// Get notifications with specific subject
$notifications = SesNotification::withSubject('Newsletter')->get();

// Get deliveries
$deliveries = SesNotification::deliveries()->get();
```

### Listening to Events

[](#listening-to-events)

The package fires events when notifications are received:

```
use Fakeeh\SecureEmail\Events\SesBounceReceived;
use Fakeeh\SecureEmail\Events\SesComplaintReceived;
use Fakeeh\SecureEmail\Events\SesDeliveryReceived;

// In your EventServiceProvider
protected $listen = [
    SesBounceReceived::class => [
        YourBounceListener::class,
    ],
    SesComplaintReceived::class => [
        YourComplaintListener::class,
    ],
    SesDeliveryReceived::class => [
        YourDeliveryListener::class,
    ],
];
```

Example listener:

```
namespace App\Listeners;

use Fakeeh\SecureEmail\Events\SesBounceReceived;

class HandleSesBounce
{
    public function handle(SesBounceReceived $event)
    {
        $notification = $event->getNotification();
        $email = $event->getEmail();

        if ($event->isPermanent()) {
            // Handle permanent bounce
            // e.g., mark user as unsubscribed
        }
    }
}
```

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

[](#configuration)

### Bounce Rules

[](#bounce-rules)

```
'rules' => [
    'bounces' => [
        'enabled' => true,
        'max_bounces' => 3, // Block after 3 bounces
        'check_by_subject' => false, // Count all bounces or just same subject
        'block_permanent_bounces' => true, // Block permanent bounces immediately
        'days_to_check' => 30, // Only count bounces in last 30 days (0 = all time)
    ],
],
```

### Complaint Rules

[](#complaint-rules)

```
'rules' => [
    'complaints' => [
        'enabled' => true,
        'max_complaints' => 1, // Block after 1 complaint
        'check_by_subject' => true, // Count complaints by subject
        'days_to_check' => 0, // Count all complaints (0 = all time)
    ],
],
```

### Custom Models

[](#custom-models)

You can use your own models by extending the package models:

```
// In your config/secure-email.php
'models' => [
    'subscription' => App\Models\CustomSnsSubscription::class,
    'notification' => App\Models\CustomSesNotification::class,
],
```

### Custom Routes

[](#custom-routes)

Customize the webhook endpoints:

```
// In your config/secure-email.php
'route_prefix' => 'webhooks/ses',
'routes' => [
    'bounces' => 'bounce-notifications',
    'complaints' => 'complaint-notifications',
    'deliveries' => 'delivery-notifications',
],
```

This will create endpoints like:

- `https://yourdomain.com/webhooks/ses/bounce-notifications`
- `https://yourdomain.com/webhooks/ses/complaint-notifications`
- `https://yourdomain.com/webhooks/ses/delivery-notifications`

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security-related issues, please email \[email protected\] instead of using the issue tracker.

Credits
-------

[](#credits)

- Inspired by [oza75/laravel-ses-complaints](https://github.com/oza75/laravel-ses-complaints)
- Built for Laravel 13 compatibility

License
-------

[](#license)

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

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

Support
-------

[](#support)

- Laravel 13.x
- PHP 8.3+

For older Laravel versions, please use a different package.

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

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance86

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~147 days

Total

2

Last Release

74d ago

Major Versions

v1.0.0 → 2.0.02026-04-21

PHP version history (2 changes)v1.0.0PHP ^8.2

2.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3d4493207208c6a97be53d6c049bcc4c0e46b6be1aa0ca03b5f373e88d8a525?d=identicon)[ash\_bendary@yahoo.com](/maintainers/ash_bendary@yahoo.com)

---

Top Contributors

[![ashrafbendary](https://avatars.githubusercontent.com/u/2691088?v=4)](https://github.com/ashrafbendary "ashrafbendary (10 commits)")

---

Tags

laravelmonitoringawsemailSNSbouncesescomplaintlaravel-13

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fakeeh-laravel-secure-email/health.svg)

```
[![Health](https://phpackages.com/badges/fakeeh-laravel-secure-email/health.svg)](https://phpackages.com/packages/fakeeh-laravel-secure-email)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

65108.9k](/packages/masterro-laravel-mail-viewer)

PHPackages © 2026

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