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
Laravel News Partners

Laravel Jobs

Medior Laravel Backend Developer (The Netherlands/Dutch only)
Nijmegen, The Netherlands
BigSpark B.V.
Laravel Developer
Remote
Enjin
Senior Laravel Backend Engineer
Remote, USA Only
Kittyhawk.io, Inc.
Full Stack Developer
Rijssen
CODE14
Senior PHP Developer
Remote
ProjectMark

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.