laravel-newsletter is a free, open source marketing & customer engagement project written in PHP and released under MIT. It has 1,639 GitHub stars, 234 forks and 1 open issues, and was last pushed 3 months ago. On this registry it ranks #34 of 50 tracked projects in Marketing & Customer Engagement, with 5 head-to-head comparisons available.

What is laravel-newsletter?

What it is

laravel-newsletter is an open-source PHP package for Laravel applications that manages newsletter subscriptions. It provides a driver-based interface for sending subscriber data to email list services, so a Laravel project can connect forms or signup flows to external newsletter infrastructure without separate provider integrations. The package lives in the Laravel ecosystem and is distributed as a Composer package under an MIT license.

The concrete problem it solves is the provider-specific work of wiring a Laravel application to newsletter services. Instead of hard-coding MailChimp, Mailcoach, or MailerLite details into application code, developers define a driver, an API key, an endpoint where required, and list identifiers in a published configuration file. The package currently supports Mailcoach, MailChimp, and MailerLite, and it can use log or null drivers to avoid direct API calls in environments where live subscriptions should not be sent.

Key capabilities

  • Integrates Laravel applications with Mailcoach, MailChimp, and MailerLite through a configurable driver class.
  • Publishes a newsletter configuration file that stores the driver, API key, endpoint, default list name, and list-specific identifiers.
  • Supports multiple named email lists, with separate configuration entries for each list and environment variables for list IDs.
  • Lets developers switch providers by changing the driver value and installing the corresponding provider package, such as the Mailcoach SDK, drewm/mailchimp-api, or mailerlite/mailerlite-php.
  • Allows a log or null driver to prevent direct calls to the provider API from a given environment.

Who uses it and how

  • Laravel developers use it to connect subscription forms or signup flows to an external email list service.
  • Teams use the published config file to centralize provider credentials and list identifiers across environments.
  • Mailcoach users install the Mailcoach SDK, then set the API key, endpoint, and email list UUID.
  • MailChimp users install drewm/mailchimp-api, set the driver to the MailChimp driver, provide an API key and list id, and set the endpoint to null.

Getting started

Install the package with composer require spatie/laravel-newsletter, then publish the configuration file with php artisan vendor:publish --tag="newsletter-config". After that, install the needed provider package and set the driver, credentials, and list identifiers in config/newsletter.php.

When to use it — and when not to

Use it when a Laravel application needs a configuration layer for subscribing users to Mailcoach, MailChimp, or MailerLite lists. Do not use it when the project requires support for other email services, because the README lists only these three integrations. It does not replace the provider itself: the application still needs a provider account, API credentials, and a working Laravel deployment, while the package focuses on subscription integration rather than broader newsletter delivery.

project readme (upstream, from github) — read inline
Logo for laravel-newsletter
</a>

Manage newsletters in Laravel

Latest Version MIT Licensed run-tests PHPStan Total Downloads

This package provides an easy way to integrate subscriptions to email lists of various email services.

Currently this package support:

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install this package via Composer using:

composer require spatie/laravel-newsletter

To publish the config file to config/newsletter.php run:

php artisan vendor:publish --tag="newsletter-config"

This will publish a file newsletter.php in your config directory with the following contents:

return [

    /*
     * The driver to use to interact with MailChimp API.
     * You may use "log" or "null" to prevent calling the
     * API directly from your environment.
     */
    'driver' => env('NEWSLETTER_DRIVER', Spatie\Newsletter\Drivers\MailcoachDriver::class),

    /**
     * These arguments will be given to the driver.
     */
    'driver_arguments' => [
        'api_key' => env('NEWSLETTER_API_KEY'),

        'endpoint' => env('NEWSLETTER_ENDPOINT'),
    ],

    /*
     * The list name to use when no list name is specified in a method.
     */
    'default_list_name' => 'subscribers',

    'lists' => [

        /*
         * This key is used to identify this list. It can be used
         * as the listName parameter provided in the various methods.
         *
         * You can set it to any string you want and you can add
         * as many lists as you want.
         */
        'subscribers' => [

            /*
             * When using the Mailcoach driver, this should be the Email list UUID
             * which is displayed in the Mailcoach UI
             *
             * When using the MailChimp driver, this should be a MailChimp list id.
             * http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id.
             *
             * When using the MailerLite driver, this should be a MailerLite group id.
             */
            'id' => env('NEWSLETTER_LIST_ID'),
        ],
    ],
];

Using Mailcoach

To let this package work with Mailcoach, you need to install the Mailcoach SDK.

composer require spatie/mailcoach-sdk-php

Next, you must provide values for the API key, endpoint and list.subscribers.id in the config file. You'll find the API key and endpoint in the Mailcoach settings screen. The value for list.subscribers.id must be the UUID of an email list on Mailcoach. You'll find this value on the settings screen of an email list

Using MailChimp

To use MailChimp, install this extra package.

composer require drewm/mailchimp-api

The driver key of the newsletter config file must be set to Spatie\Newsletter\Drivers\MailChimpDriver::class.

Next, you must provide values for the API key and list.subscribers.id. You'll find these values in the MailChimp UI.

The endpoint config value must be set to null.

Using MailerLite

To use MailerLite, install this extra package.

composer require mailerlite/mailerlite-php

The driver key of the newsletter config file must be set to Spatie\Newsletter\Drivers\MailerLiteDriver::class.

You need to provide the API key and the group.id. These can be found in your MailerLite Dashboard under Integrations > API.

The endpoint config value must be set to null.

Usage

After you've installed the package and filled in the values in the config-file working with this package will be a breeze. All the following examples use the facade. Don't forget to import it at the top of your file.

use Spatie\Newsletter\Facades\Newsletter;

Subscribing, updating and unsubscribing

Subscribing an email address can be done like this:

use Newsletter;

Newsletter::subscribe('[email protected]');

Let's unsubscribe someone:

Newsletter::unsubscribe('[email protected]');

For Mailcoach, you can pass extra attributes as the second argument:

Newsletter::subscribe('[email protected]', ['first_name' => 'Rince', 'last_name' => 'Wind']);

For MailChimp you can pass merge variables as the second argument:

Newsletter::subscribe('[email protected]', ['FNAME'=>'Rince', 'LNAME'=>'Wind']);

For MailerLite you can pass subscriber fields as the second argument:

Newsletter::subscribe('[email protected]', ['name'=>'Rince', 'last_name'=>'Wind']);

You can subscribe someone to a specific list by passing a list name:

Newsletter::subscribe('[email protected]', listName: 'subscribers');

That third argument is the name of a list you configured in the config file.

You can also subscribe and/or update someone. The person will be subscribed or updated if he/she is already subscribed:

Newsletter::subscribeOrUpdate('[email protected]', ['first_name' => 'Rince', 'last_name' => 'Wind']);

For MailChimp, You can subscribe someone to one or more specific group(s)/interest(s) by using the fourth argument:

Newsletter::subscribeOrUpdate(
   '[email protected]', 
   ['FNAME'=>'Rince','LNAME'=>'Wind'], 
   'subscribers', 
   ['interests'=>['interestId'=>true, 'interestId'=>true]],
);

Simply add false if you want to remove someone from a group/interest.

Here's how to unsubscribe someone from a specific list:

Newsletter::unsubscribe('[email protected]', 'subscribers');

For MailerLite, passing a list name as the second argument removes the subscriber from the matching group. Without a list name, the subscriber is marked as unsubscribed across the account.

Deleting subscribers

Deleting is not the same as unsubscribing. Unlike unsubscribing, deleting a member will result in the loss of all history (add/opt-in/edits) as well as removing them from the list. In most cases, you want to use unsubscribe instead of delete.

Here's how to perform a delete:

Newsletter::delete('[email protected]');

Getting subscriber info

You can get information on a subscriber by using the getMember function:

Newsletter::getMember('[email protected]');

For MailCoach, this will return an instance of Spatie\Mailcoach\Resources|Subscriber For MailChimp, this will return an array with information on the subscriber.

If there's no one subscribed with that e-mail address the function will return false

There's also a convenient method to check if someone is already subscribed:

Newsletter::hasMember('[email protected]'); //returns a boolean

In addition to this, you can also check if a user is subscribed to your list:

Newsletter::isSubscribed('[email protected]'); //returns a boolean

Need something else?

If you need more functionality you get an instance of the underlying API with

$api = Newsletter::getApi();

If you're having trouble getting the MailChimp integration, you can see the last error with:

Newsletter

readme truncated — read the full docs on github

Frequently asked questions

Is laravel-newsletter free to use?

laravel-newsletter is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does laravel-newsletter do?

Manage newsletters in Laravel

What is laravel-newsletter written in?

laravel-newsletter is primarily written in PHP. Its source is publicly available at https://github.com/spatie/laravel-newsletter, and it has 1,639 GitHub stars.