PHPackages                             mostafanobaghi/snooze - 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. mostafanobaghi/snooze

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

mostafanobaghi/snooze
=====================

Schedule future notifications and reminders in Laravel

0671PHP

Since Sep 12Pushed 2y agoCompare

[ Source](https://github.com/MostafaNobaghi/snooze)[ Packagist](https://packagist.org/packages/mostafanobaghi/snooze)[ RSS](/packages/mostafanobaghi-snooze/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Snooze
==============

[](#laravel-snooze)

> Schedule future notifications and reminders in Laravel

 [![](./snooze-logo-v1.png)](./snooze-logo-v1.png)

[![Build Status](https://camo.githubusercontent.com/e45175ad0de940db95b618359e0aab36d7d5b8b9382684b691628fe2f1967542/68747470733a2f2f7472617669732d63692e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/thomasjohnkane/snooze)[![styleci](https://camo.githubusercontent.com/cd33d8e797eff5c400adbbb41d9a14f8a3038fa6066264a3c69fe50fb2cb77f7/68747470733a2f2f7374796c6563692e696f2f7265706f732f3137333234363332392f736869656c64)](https://styleci.io/repos/173246329)

[![Latest Stable Version](https://camo.githubusercontent.com/797e811d1c00db6c31bfa52c0751a34e0b3747e87662d2f91171b630b799cb19/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652f762f737461626c65)](https://packagist.org/packages/thomasjohnkane/snooze)[![Total Downloads](https://camo.githubusercontent.com/629512c2755774c473551dcdf285b433556e65bfdef450c84688e51e5a14250f/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652f646f776e6c6f616473)](https://packagist.org/packages/thomasjohnkane/snooze)[![License](https://camo.githubusercontent.com/4505e40346e01fbacc6499e0db69fc0791bd8690b67a2d38a6f60f42d5b6cfef/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652f6c6963656e7365)](https://packagist.org/packages/thomasjohnkane/snooze)

### Why use this package?

[](#why-use-this-package)

- Ever wanted to schedule a **future** notification to go out at a specific time? (was the delayed queue option not enough?)
- Want a simple on-boarding email drip?
- How about happy birthday emails?

#### Common use cases

[](#common-use-cases)

- Reminder system (1 week before appt, 1 day before, 1 hour before, etc)
- Follow-up surveys (2 days after purchase)
- On-boarding Email Drips (Welcome email after sign-up, additional tips after 3 days, upsell offer after 7 days)
- Short-Term Recurring reports (send every week for the next 4 weeks)

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

[](#installation)

Install via composer

```
composer require thomasjohnkane/snooze
```

```
php artisan migrate
```

### Publish Configuration File

[](#publish-configuration-file)

```
php artisan vendor:publish --provider="Thomasjohnkane\Snooze\ServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

#### Using the model trait

[](#using-the-model-trait)

Snooze provides a trait for your model, similar to the standard `Notifiable` trait. It adds a `notifyAt()` method to your model to schedule notifications.

```
use Thomasjohnkane\Snooze\Traits\SnoozeNotifiable;
use Illuminate\Notifications\Notifiable;

class User extends Model {
    use Notifiable, SnoozeNotifiable;

    // ...
}

// Schedule a birthday notification
$user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday));

// Schedule for a week from now
$user->notifyAt(new NextWeekNotification, Carbon::now()->addDays(7));

// Schedule for new years eve
$user->notifyAt(new NewYearNotification, Carbon::parse('last day of this year'));
```

#### Using the ScheduledNotification::create helper

[](#using-the-schedulednotificationcreate-helper)

You can also use the `create` method on the `ScheduledNotification`.

```
ScheduledNotification::create(
     Auth::user(), // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addHour() // Send At
);
```

This is also useful for scheduling anonymous notifications (routed direct, rather than on a model).

```
$target = (new AnonymousNotifiable)
    ->route('mail', 'hello@example.com')
    ->route('sms', '56546456566');

ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay() // Send At
);
```

#### An important note about scheduling the `snooze:send` command

[](#an-important-note-about-scheduling-the-snoozesend-command)

Creating a scheduled notification will add the notification to the database. It will be sent by running `snooze:send` command at (or after) the stored `sendAt` time.

The `snooze:send` command is scheduled to run every minute by default. You can change this value (`sendFrequency`) in the published config file. Available options are `everyMinute`, `everyFiveMinutes`, `everyTenMinutes`, `everyFifteenMinutes`, `everyThirtyMinutes`, `hourly`, and `daily`.

The only thing you need to do is make sure `schedule:run` is also running. You can test this by running `php artisan schedule:run` in the console. [To make it run automatically, read here](https://laravel.com/docs/5.7/scheduling#introduction "Configure Laravel Scheduler").

> Note: If you would prefer snooze to not automatically schedule the commands, you can set the `scheduleCommands` config value to `false`

### Setting the send tolerance

[](#setting-the-send-tolerance)

If your scheduler stops working, a backlog of scheduled notifications will build up. To prevent users receiving all of the old scheduled notifications at once, the command will only send mail within the configured tolerance. By default this is set to 24 hours, so only mail scheduled to be sent within that window will be sent. This can be configured (in seconds) using the `SCHEDULED_NOTIFICATION_SEND_TOLERANCE` environment variable or in the `snooze.php` config file.

### Setting the prune age

[](#setting-the-prune-age)

The package can prune sent and cancelled messages that were sent/cancelled more than x days ago. You can configure this using the `SCHEDULED_NOTIFICATION_PRUNE_AGE` environment variable or in the `snooze.php` config file (unit is days). This feature is turned off by default.

#### Detailed Examples

[](#detailed-examples)

- [Delayed Notification (1 week)](./docs/examples/basic-delayed-notification.md "Delayed 1 Week Example")
- [Simple On-boarding Email Drip](./docs/examples/on-boarding-email-drip.md "On-boarding Drip Example")
- [Exposing Custom Data to the Notification/Email](./docs/examples/custom-data-example.md "Custom Data Example")

**Cancelling Scheduled Notifications**

```
$notification->cancel();
```

**Note:** you cannot cancel a notification that has already been sent.

**Rescheduling Scheduled Notifications**

```
$rescheduleAt = Carbon::now()->addDay(1)

$notification->reschedule($rescheduleAt)
```

**Note:** you cannot reschedule a notification that has already been sent or cancelled. If you want to duplicate a notification that has already been sent or cancelled, pass a truthy second parameter along with the new send date; `reschedule($date, true)`, or use the `scheduleAgainAt($date)` method shown below.

**Duplicate a Scheduled Notification to be sent again**

```
$notification->scheduleAgainAt($newDate); // Returns the new (duplicated) $notification
```

**Check a scheduled notification's status**

```
// Check if a notification is already cancelled

$result = $notification->isCancelled(); // returns a bool

// Check if a notification is already sent

$result = $notification->isSent(); // returns a bool
```

**Conditionally interrupt a scheduled notification**

If you'd like to stop an email from being sent conditionally, you can add the `shouldInterrupt()` method to any notification. This method will be checked immediately before the notification is sent.

For example, you might not send a future drip notification if a user has become inactive, or the order the notification was for has been canceled.

```
public function shouldInterrupt($notifiable) {
    return $notifiable->isInactive() || $this->order->isCanceled();
}
```

If this method is not present on your notification, the notification will *not* be interrupted. Consider creating a shouldInterupt trait if you'd like to repeat conditional logic on groups of notifications.

**Scheduled Notification Meta Information**

It's possible to store meta information on a scheduled notification, and then query the scheduled notifications by this meta information at a later stage.

This functionality could be useful for when you store notifications for a future date, but some change in the system requires you to update them. By using the meta column, it's possible to more easily query these scheduled notifications from the database by something else than the notifiable.

***Storing Meta Information***

Using the `ScheduledNotification::create` helper

```
ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay(), // Send At,
     ['foo' => 'bar'] // Meta Information
);
```

Using the `notifyAt` trait

```
  $user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday), ['foo' => 'bar']);
```

***Retrieving Meta Information from Scheduled Notifications***

You can call the `getMeta` function on an existing scheduled notification to retrieve the meta information for the specific notification.

Passing no parameters to this function will return the entire meta column in array form.

Passing a string key (`getMeta('foo')`), will retrieve the specific key from the meta column.

***Querying Scheduled Notifications using the ScheduledNotification::findByMeta helper***

It's possible to query the database for scheduled notifications with certain meta information, by using the `findByMeta` helper.

```
  ScheduledNotification::findByMeta('foo', 'bar'); //key and value
```

The first parameter is the meta key, and the second parameter is the value to look for.

> Note: The index column doesn't currently make use of a database index

**Conditionally turn off scheduler**

If you would like to disable sending of scheduled notifications, set an env variable of `SCHEDULED_NOTIFICATIONS_DISABLED` to `true`. You will still be able to schedule notifications, and they will be sent once the scheduler is enabled.

This could be useful for ensuring that scheduled notifications are only sent by a specific server, for example.

**Enable onOneServer**

If you would like the `snooze` commands to utilise the Laravel Scheduler's `onOneServer` functionality, you can use the following environment variable:

```
SCHEDULED_NOTIFICATIONS_ONE_SERVER = true
```

Running the Tests
-----------------

[](#running-the-tests)

```
composer test
```

Security
--------

[](#security)

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

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

[](#contributing)

1. Fork it ()
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

Credits
-------

[](#credits)

- [Thomas Kane &amp;&amp; Flux Bucket](https://github.com/thomasjohnkane)
- [Atymic](https://github.com/atymic)
- [All contributors](https://github.com/thomasjohnkane/snooze/graphs/contributors)

This package is bootstrapped with the help of [melihovv/laravel-package-generator](https://github.com/melihovv/laravel-package-generator).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.6% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f2e250e3c29920fa3ecfa11d34c786943c9a9334116f6b8a16af7b9cf5f3801?d=identicon)[MostafaNobaghi](/maintainers/MostafaNobaghi)

---

Top Contributors

[![thomasjohnkane](https://avatars.githubusercontent.com/u/8945177?v=4)](https://github.com/thomasjohnkane "thomasjohnkane (50 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (31 commits)")[![ricuss](https://avatars.githubusercontent.com/u/17425015?v=4)](https://github.com/ricuss "ricuss (3 commits)")[![danielsimkus](https://avatars.githubusercontent.com/u/8949315?v=4)](https://github.com/danielsimkus "danielsimkus (1 commits)")[![elishaukpong](https://avatars.githubusercontent.com/u/31503827?v=4)](https://github.com/elishaukpong "elishaukpong (1 commits)")[![ettiennelouw](https://avatars.githubusercontent.com/u/1754421?v=4)](https://github.com/ettiennelouw "ettiennelouw (1 commits)")[![gborcherds](https://avatars.githubusercontent.com/u/7691166?v=4)](https://github.com/gborcherds "gborcherds (1 commits)")[![gpanos](https://avatars.githubusercontent.com/u/12728267?v=4)](https://github.com/gpanos "gpanos (1 commits)")[![joe-pritchard](https://avatars.githubusercontent.com/u/25373032?v=4)](https://github.com/joe-pritchard "joe-pritchard (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![MostafaNobaghi](https://avatars.githubusercontent.com/u/24896868?v=4)](https://github.com/MostafaNobaghi "MostafaNobaghi (1 commits)")[![thdebay](https://avatars.githubusercontent.com/u/1422621?v=4)](https://github.com/thdebay "thdebay (1 commits)")[![colq2](https://avatars.githubusercontent.com/u/25695283?v=4)](https://github.com/colq2 "colq2 (1 commits)")[![azarzag](https://avatars.githubusercontent.com/u/3733255?v=4)](https://github.com/azarzag "azarzag (1 commits)")

### Embed Badge

![Health badge](/badges/mostafanobaghi-snooze/health.svg)

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M228](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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