Subscribable Notifications

Subscribable Notifications

Subscribable Notifications is a Laravel package by Peter Fox for adding unsubscribe links to notifications:

This package is designed to help you handle email unsubscribes with as little as 5 minutes setup. After installing your notifications sent over email should now be delivered with unsubscribe links in the footer and as a mail header which email clients can present to the user for quicker unsubscribing. It can also handle resolving the unsubscribing of the user through a signed route/controller.

This package works by implementing the CanUnsubscribe interface on the User model, along with an optional trait that fulfills the interface on your model. You can also write a custom implementation using the interface, for example:

public function unsubscribeLink(?string $mailingList = ''): string
{
    return URL::signedRoute(
        'sorry-to-see-you-go,
        ['subscriber' => $this, 'mailingList' => $mailingList],
        now()->addDays(1);
    );
}

You can also apply specific mailing lists to notifications using the AppliesToMailingList trait on the notifications on which you wish to support this feature. Using this feature provides two links at the bottom of email notifications: one for unsubscribing from all emails and another for only unsubscribing from a specific type of notification.

This package provides a lot of customization options both in the logic of unsubscribing as well as the templates. You can learn more about this package, get full installation instructions, and view the source code on GitHub at ylsideas/subscribable-notifications.


Filed in: News


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Mid / Sen. Software Engineer
Clearwater, FL
ShineOn
Remote PHP / Laravel Developer
Remote
SpringboardVR
Senior PHP/Laravel Developer: Your Dream Work Environment
Remote
iPhone Photography School
Senior Laravel Developer
Leidseplein, Amsterdam
Orderchamp.com
PHP Developer
Remote
X-Team
Senior Laravel Developer (Canada and India)
London, Ontario, Canada
Factory Bucket Inc.
Laravel, PHP, PostgreSQL, Neo4J Developer
Pune, India (intern in Denver, CO)
Life AI