PHPackages                             eugenefvdm/notification-subscriptions - 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. eugenefvdm/notification-subscriptions

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

eugenefvdm/notification-subscriptions
=====================================

A Laravel package for managing email subscriptions, repeat emails, and delayed sending

v0.10(1mo ago)01.1kMITPHPCI passing

Since May 30Pushed 1mo agoCompare

[ Source](https://github.com/eugenefvdm/notification-subscriptions)[ Packagist](https://packagist.org/packages/eugenefvdm/notification-subscriptions)[ RSS](/packages/eugenefvdm-notification-subscriptions/feed)WikiDiscussions main Synced 1mo ago

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

Notification Subscriptions
==========================

[](#notification-subscriptions)

[![Tests](https://github.com/eugenefvdm/notification-subscriptions/actions/workflows/run-tests.yml/badge.svg)](https://github.com/eugenefvdm/notification-subscriptions/actions/workflows/run-tests.yml/badge.svg)[![Downloads](https://camo.githubusercontent.com/76db97e5a73be3d59da30e3cadf99f09dd1a207a0f9ff030f242e75ead587325/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f657567656e656676646d2f6e6f74696669636174696f6e2d737562736372697074696f6e732e737667)](https://packagist.org/packages/eugenefvdm/notification-subscriptions)

Notification Subscriptions is a Laravel package that may be used to keep track of repeat emails, delayed emails, and unsubscribing of email notifications.

The package makes use of Laravel's built-in event listeners `NotificationSending` and `NotificationSent` to automatically subscribe and to determine if and when a message should be sent.

Categorization of emails and model specific subscriptions are possible.

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

[](#requirements)

- Laravel 11 or 12

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

[](#installation)

```
composer require eugenefvdm/notification-subscriptions
```

After installing the package, run the migrations:

```
php artisan migrate
```

This will create the `notification_templates` and `notification_subscriptions` tables.

If you want to customize the unsubscribe link or `unsubscribed` confirmation blade, publish the views:

```
php artisan vendor:publish --tag="notification-subscriptions-views"
```

### User Model

[](#user-model)

Add the `HasNotificationSubscriptions` trait to your `User` model:

```
use Eugenefvdm\NotificationSubscriptions\Traits\HasNotificationSubscriptions;

class User extends Authenticatable
{
    /** @use HasFactory */
    use HasFactory, Notifiable;
    use HasNotificationSubscriptions;
```

Usage
-----

[](#usage)

Generate notifications as per usual using `php artisan`:

```
php artisan make:notification DailyReminder --markdown=reminders.daily
```

Extend the newly created notification with the BaseNotification class:

```
use Eugenefvdm\NotificationSubscriptions\Notifications\BaseNotification;

class DailyReminder extends BaseNotification
{
    use Queueable;
```

Repeat Settings
---------------

[](#repeat-settings)

In your notification class, add any or all of the following variables to do repeated notifications:

```
use Eugenefvdm\NotificationSubscriptions\Enums\RepeatFrequency;
use Eugenefvdm\NotificationSubscriptions\Notifications\BaseNotification;

class DailyReminder extends BaseNotification
{
    use Queueable;

    public static ?string $repeatFrequency = RepeatFrequency::Daily;
    public static ?int $repeatInterval = 4; // optional
    public static ?int $maxRepeats = 3; // optional defaults to 1
```

Delayed Sending
---------------

[](#delayed-sending)

To wait a certain amount of time before sending a notification, set `initialDelay` in your constructor:

```
use Eugenefvdm\NotificationSubscriptions\Notifications\BaseNotification;

class DailyReminder extends BaseNotification
{
    use Queueable;

    public static ?Carbon $initialDelay = null;

    /**
     * Create a new notification instance.
     */
    public function __construct()
    {
        self::$initialDelay = Carbon::now()->addWeek();
    }
```

Categorization
--------------

[](#categorization)

All new messages without an explicit category assignment will be assigned to the `default` category in the database.

To specify a custom category, use `$category`:

```
use Eugenefvdm\NotificationSubscriptions\Notifications\BaseNotification;

class DailyReminder extends BaseNotification
{
    use Queueable;

    public static ?string $category = 'reminders';
```

Model Specific Subscriptions
----------------------------

[](#model-specific-subscriptions)

Notifications are typically tied to a user, but at times one wants to associate a notification to both a user and another model. For example, you might have a `products` table, and you want a user to be subscribed to a price notification for specific `Product` models. Here's how:

```
use Eugenefvdm\NotificationSubscriptions\Notifications\BaseNotification;
use Illuminate\Database\Eloquent\Model;
use App\Models\Product;

class ProductPriceNotification extends BaseNotification
{
    use Queueable;

    public ?Model $customModel; // Override $customModel

    public function __construct(Product $product) // Type-hint Product in constructor
    {
        $this->customModel = $product;
    }

    public function toMail(object $notifiable): MailMessage
    {
        /** @var Product $product */
        $product = $this->customModel;

        return (new MailMessage)
            ->subject("Price Update for {$product->name}")
            ->markdown('notification.product-price-update', [
                'product' => $product,
                'subscription' => $this->getSubscriptionFromNotifiable($notifiable)
            ]);
    }
}
```

Unsubscribe
-----------

[](#unsubscribe)

Any new notification will be automatically subscribed when used the first time.

### Adding the Unsubscribe Link in Blades

[](#adding-the-unsubscribe-link-in-blades)

For unsubscribe links, modify the `toMail` method in the notification class:

```
/**
 * Get the mail representation of the notification.
 */
public function toMail(object $notifiable): MailMessage
{
    return (new MailMessage)
        ->markdown('notification.reminders.max-count', [
            'subscription' => $this->getSubscriptionFromNotifiable($notifiable)
        ]);
}
```

Then add this to your blade:

```

```

The invokable controller for unsubscribe will direct the user to a generic `unsubcribed.blade.php` file that may be customized. The variables returned to this blade are:

```
$result = [
    'success' => 'true|false',
    'message' => '$message',
    'template' => NotificationTemplate instance
]
```

Possible `$message` values are:

- Subscription not found
- The $template-&gt;name\_with\_spaces notification cannot be unsubscribed
- You are already unsubscribed from the '$template-&gt;name\_with\_spaces' notification
- Successfully unsubscribed from the '$template-&gt;name\_with\_spaces' notification

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

Alternatives
------------

[](#alternatives)

- [mail-tracker](https://github.com/jdavidbakr/mail-tracker) - A Laravel package that injects tracking code into outgoing emails and provides an interface to view sent emails, track opens, and monitor link clicks.

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance96

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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 ~32 days

Recently: every ~59 days

Total

10

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/932743c076390240ecdefe58dc5f81b60cb5fe9ed38b3bead0541f640a7bb2a8?d=identicon)[eugenevdm](/maintainers/eugenevdm)

---

Top Contributors

[![eugenefvdm](https://avatars.githubusercontent.com/u/1836436?v=4)](https://github.com/eugenefvdm "eugenefvdm (50 commits)")

---

Tags

emaillaravelnotificationssubscribeunsubscribe

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/eugenefvdm-notification-subscriptions/health.svg)

```
[![Health](https://phpackages.com/badges/eugenefvdm-notification-subscriptions/health.svg)](https://phpackages.com/packages/eugenefvdm-notification-subscriptions)
```

###  Alternatives

[spatie/laravel-failed-job-monitor

Get notified when a queued job fails

1.0k2.6M4](/packages/spatie-laravel-failed-job-monitor)[vemcogroup/laravel-sparkpost-driver

SparkPost driver to use with Laravel 6.x|7.x|8.x|9.x|10.x

421.7M1](/packages/vemcogroup-laravel-sparkpost-driver)[spatie/mailcoach

Self-host Mailcoach

4007.0k](/packages/spatie-mailcoach)[synergitech/laravel-postal

This library integrates Postal with the standard Laravel mail framework.

38107.1k](/packages/synergitech-laravel-postal)[motomedialab/smtp2go

Send emails via API using the first-class email courier SMTP2Go

1316.3k](/packages/motomedialab-smtp2go)

PHPackages © 2026

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