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 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Full Stack PHP Developer (Laravel)
Remote
MAPPEN
Senior Laravel Developer
Remote
ACTO
Senior Full-Stack Engineer
[REMOTE: USA Only]
Curricula
Developers for B2B eCommerce SaaS, AWS serverless, Laravel, Vue, Python
Remote, full time EU only
ES Tech Group
Senior PHP Developer (Laravel)
Remote
The Interaction Design Foundation