PHPackages                             spatie/laravel-newsletter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. spatie/laravel-newsletter

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

spatie/laravel-newsletter
=========================

Manage Mailcoach and MailChimp newsletters in Laravel

5.3.2(2mo ago)1.6k6.3M—6.8%238[1 PRs](https://github.com/spatie/laravel-newsletter/pulls)20MITPHPPHP ^8.1CI passing

Since May 7Pushed 2mo ago37 watchersCompare

[ Source](https://github.com/spatie/laravel-newsletter)[ Packagist](https://packagist.org/packages/spatie/laravel-newsletter)[ Docs](https://github.com/spatie/laravel-newsletter)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/spatie-laravel-newsletter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (57)Used By (20)

 [   ![Logo for laravel-newsletter](https://camo.githubusercontent.com/4bd2af0464d99ad3d9fe463c1f21fd37fa0c72c04a00dee009ce9aee4ce96aeb/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c61726176656c2d6e6577736c65747465722f68746d6c2f6c696768742e77656270)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-newsletter)Manage newsletters in Laravel
=============================

[](#manage-newsletters-in-laravel)

[![Latest Version](https://camo.githubusercontent.com/81012f310481681553b6c8d216352780d3f3f6deb58d3728dd7d57edcf0ab487/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7370617469652f6c61726176656c2d6e6577736c65747465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-newsletter/releases)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![run-tests](https://github.com/spatie/laravel-newsletter/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-newsletter/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/spatie/laravel-newsletter/actions/workflows/phpstan.yml/badge.svg)](https://github.com/spatie/laravel-newsletter/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/8151b7c363aa96d092fa0494295f966145d3dc6bd0c8d8ab50e7a048259ef944/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6e6577736c65747465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-newsletter)

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

Currently this package support:

- [Mailcoach](https://mailcoach.app) (built by us :-))
- [MailChimp](https://mailchimp.com)

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/fb88cebedd69296831d76fb6434787b42083296310fffc5524e488f51a4ebe5d/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6e6577736c65747465722e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-newsletter)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

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](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#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.
             */
            'id' => env('NEWSLETTER_LIST_ID'),
        ],
    ],
];
```

### Using Mailcoach

[](#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](https://mailcoach.app) 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

[](#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.

Usage
-----

[](#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-updating-and-unsubscribing)

Subscribing an email address can be done like this:

```
use Newsletter;

Newsletter::subscribe('rincewind@discworld.com');
```

Let's unsubscribe someone:

```
Newsletter::unsubscribe('the.luggage@discworld.com');
```

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

```
Newsletter::subscribe('rincewind@discworld.com', ['first_name' => 'Rince', 'last_name' => 'Wind']);
```

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

```
Newsletter::subscribe('rincewind@discworld.com', ['FNAME'=>'Rince', 'LNAME'=>'Wind']);
```

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

```
Newsletter::subscribe('rincewind@discworld.com', 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('rincewind@discworld.com', ['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(
   'rincewind@dscworld.com',
   ['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('rincewind@discworld.com', 'subscribers');
```

### Deleting subscribers

[](#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('rincewind@discworld.com');
```

### Getting subscriber info

[](#getting-subscriber-info)

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

```
Newsletter::getMember('lord.vetinari@discworld.com');
```

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('nanny.ogg@discworld.com'); //returns a boolean
```

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

```
Newsletter::isSubscribed('lord.vetinari@discworld.com'); //returns a boolean
```

### Need something else?

[](#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::getApi()->getLastError();
```

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/pest
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

75

—

ExcellentBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity70

Solid adoption and visibility

Community46

Growing community involvement

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 61.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~146 days

Total

53

Last Release

86d ago

Major Versions

0.0.1 → 1.0.02015-05-07

1.1.0 → 2.0.02015-06-24

2.2.0 → 3.0.02016-04-22

3.7.0 → 4.0.02017-08-30

v4.x-dev → 5.0.02022-11-10

PHP version history (9 changes)0.0.1PHP &gt;=5.4.0

3.0.0PHP ^5.5|^7.0

3.2.0PHP ~5.6|~7.0

4.0.0PHP ~7.0

4.2.3PHP ~7.1

4.3.0PHP ~7.2

4.8.1PHP ^7.3

4.9.0PHP ^7.3|^8.0

5.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (164 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (15 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (13 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (9 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (7 commits)")[![aerni](https://avatars.githubusercontent.com/u/23167701?v=4)](https://github.com/aerni "aerni (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![jochensengier](https://avatars.githubusercontent.com/u/10118729?v=4)](https://github.com/jochensengier "jochensengier (5 commits)")[![lartisan](https://avatars.githubusercontent.com/u/7920412?v=4)](https://github.com/lartisan "lartisan (5 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (4 commits)")[![jasonmccreary](https://avatars.githubusercontent.com/u/161071?v=4)](https://github.com/jasonmccreary "jasonmccreary (3 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (3 commits)")[![d-jimenez](https://avatars.githubusercontent.com/u/74740646?v=4)](https://github.com/d-jimenez "d-jimenez (2 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (2 commits)")[![arondeparon](https://avatars.githubusercontent.com/u/7697?v=4)](https://github.com/arondeparon "arondeparon (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (2 commits)")[![shuvroroy](https://avatars.githubusercontent.com/u/21066418?v=4)](https://github.com/shuvroroy "shuvroroy (2 commits)")[![amosmos](https://avatars.githubusercontent.com/u/2318695?v=4)](https://github.com/amosmos "amosmos (1 commits)")

---

Tags

laravelmailchimpmailchimp-apimailcoachnewsletterphplaravelmailchimpnewslettermailcoach

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-laravel-newsletter/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-newsletter/health.svg)](https://phpackages.com/packages/spatie-laravel-newsletter)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[spatie/laravel-mailcoach-mailer

The driver for sending transactional mails using Mailcoach in Laravel

25325.1k](/packages/spatie-laravel-mailcoach-mailer)[spatie/laravel-discord-alerts

Send a message to Discord

151408.0k](/packages/spatie-laravel-discord-alerts)[hocza/sendy

Sendy API implementation for Laravel

71195.5k](/packages/hocza-sendy)[spatie/laravel-mailcoach-sdk

An SDK to easily work with the Mailcoach API in Laravel apps

41290.2k1](/packages/spatie-laravel-mailcoach-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
