Unsubscribing from a list

You can add an unsubscribe link by adding an ::unsubscribeUrl:: placeholder to the HTML of your campaign.

When a subscriber visits the actual unsubscribe URL, a simple message will be displayed to confirming that they have successfully unsubscribed.

To customize this confirmation message, publish the views.

php artisan vendor:publish --provider="Spatie\EmailCampaigns\EmailCampaignsServiceProvider" --tag="views"

Now we modify the following views in the /resources/views/vendor/email-campaigns/unsubscribe/ directory:

  • unsubscribed.blade.php
  • notFound.blade.php

Unsubscribing manually

You can also unsubscribe someone manually like this.

$emailList->unsubscribe('john@example.com');

Alternatively, you can call unsubscribe on a subscriber

Subscriber::findForEmail('john@example.com')->unsubscribe();

Unsubscribing using an email client

Emails sent have the List-Unsubscribe header included. This allows for users to unsubscribe from their email client as per RFC2369.

Permanently deleting a subscriber

Behind the scenes, the subscriber and the subscription will not be deleted. Instead, the status of the subscription will be updated to unsubscribed. If you want to delete a subscription outright, you can call delete on it.

$emailList->getSubscription('john@example.com')->delete();

If you want to delete a subscriber entirely, you can call delete on it.

Subscriber::findForEmail('john@example.com')->delete();

The code above will also delete all related subscriptions.