PHPackages                             thedigit/laravel5.7-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. thedigit/laravel5.7-newsletter

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

thedigit/laravel5.7-newsletter
==============================

Manage newsletters in Laravel

4.2.1(8y ago)0130MITPHPPHP ~7.0

Since May 7Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Thedigit/laravel-newsletter)[ Packagist](https://packagist.org/packages/thedigit/laravel5.7-newsletter)[ Docs](https://github.com/spatie/laravel-newsletter)[ RSS](/packages/thedigit-laravel57-newsletter/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (30)Used By (0)

Manage newsletters in Laravel
=============================

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

[![Latest Version](https://camo.githubusercontent.com/81012f310481681553b6c8d216352780d3f3f6deb58d3728dd7d57edcf0ab487/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7370617469652f6c61726176656c2d6e6577736c65747465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-newsletter/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/7710e461cfc30757ba12171e127b75697a71eab81493ef0a1a74d04b1f1c8a70/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f6c61726176656c2d6e6577736c65747465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/laravel-newsletter)[![Quality Score](https://camo.githubusercontent.com/bac0d5b1a15ea16d3e3c860360677d65a18cec99612a2caf5996407c557bf2c7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d6e6577736c65747465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-newsletter)[![StyleCI](https://camo.githubusercontent.com/ba688d98e9e7fe603f28f44d3a764f658c654d8f29626247ad493b6699cda700/68747470733a2f2f7374796c6563692e696f2f7265706f732f33353033353931352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/35035915)[![Total Downloads](https://camo.githubusercontent.com/8151b7c363aa96d092fa0494295f966145d3dc6bd0c8d8ab50e7a048259ef944/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6e6577736c65747465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-newsletter)

This package provides an easy way to integrate MailChimp with Laravel 5. Behind the scenes v3 for the MailChimp API is used. Here are some examples of what you can do with the package:

> Please note the at the time of this writing the default merge variables in MailChimp are named `FNAME` and `LNAME`. In our examples we use `firstName` and `lastName` for extra readability. Make sure you rename those merge variables at MailChimp in order to make these examples work.

```
// at the top of your class
use Newsletter;

// ...

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

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

//Merge variables can be passed as the second argument
Newsletter::subscribe('sam.vines@discworld.com', ['firstName'=>'Sam', 'lastName'=>'Vines']);

//Subscribe someone to a specific list by using the third argument:
Newsletter::subscribe('nanny.ogg@discworld.com', ['firstName'=>'Nanny', 'lastName'=>'Ogg'], 'Name of your list');

//Subscribe someone to a specific list and require them to confirm via email:
Newsletter::subscribePending('nanny.ogg@discworld.com', ['firstName'=>'Nanny', 'lastName'=>'Ogg'], 'Name of your list');

//Subscribe or update someone
Newsletter::subscribeOrUpdate('sam.vines@discworld.com', ['firstName'=>'Foo', 'lastName'=>'Bar']);

// Change the email address of an existing subscriber
Newsletter::updateEmailAddress('rincewind@discworld.com', 'the.luggage@discworld.com');

//Get some member info, returns an array described in the official docs
Newsletter::getMember('lord.vetinari@discworld.com');

//Get the member activity, returns an array with recent activity for a given user
Newsletter::getMemberActivity('lord.vetinari@discworld.com');

//Get the members for a given list, optionally filtered by passing a second array of parameters
Newsletter::getMembers();

//Check if a member is subscribed to a list
Newsletter::isSubscribed('rincewind@discworld.com');

//Returns a boolean
Newsletter::hasMember('greebo@discworld.com');

//If you want to do something else, you can get an instance of the underlying API:
Newsletter::getApi();
```

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

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

[](#installation)

You can install this package via composer using:

```
composer require spatie/laravel-newsletter
```

The package will automatically register itself.

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

```
php artisan vendor:publish --provider="Spatie\Newsletter\NewsletterServiceProvider"
```

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

```
return [

    /*
     * The API key of a MailChimp account. You can find yours at
     * https://us10.admin.mailchimp.com/account/api-key-popup/.
     */
    'apiKey' => env('MAILCHIMP_APIKEY'),

    /*
     * The listName to use when no listName has been specified in a method.
     */
    'defaultListName' => 'subscribers',

    /*
     * Here you can define properties of the lists.
     */
    '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' => [

            /*
             * A MailChimp list id. Check the MailChimp docs if you don't know
             * how to get this value:
             * http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id.
             */
            'id' => env('MAILCHIMP_LIST_ID'),
        ],
    ],

    /*
     * If you're having trouble with https connections, set this to false.
     */
    'ssl' => true,

];
```

Updating from 3.x to 4.x
------------------------

[](#updating-from-3x-to-4x)

There is a new name for our config file. We've changed the name from `laravel-newsletter.php` to `newsletter.php`.

If you are upgrading to 4.x, package is looking for the new config file name. In that case, you have to rename the file in your `app\config` folder.

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 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');
```

You can pass some merge variables as the second argument:

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

> Please note the at the time of this writing the default merge variables in MailChimp are named `FNAME` and `LNAME`. In our examples we use `firstName` and `lastName` for extra readability.

You can subscribe someone to a specific list by using the third argument:

```
Newsletter::subscribe('rincewind@discworld.com', ['firstName'=>'Rince', 'lastName'=>'Wind'], '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', ['firstName'=>'Foo', 'lastname'=>'Bar']);
```

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

```
Newsletter::subscribeOrUpdate('rincewind@dscworld.com', ['firstName'=>'Rince','lastName'=>'Wind'], 'subscribers', ['interests'=>['interestId'=>true, 'interestId'=>true]])
```

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

You can also 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');
```

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 convenience 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
```

### Creating a campaign

[](#creating-a-campaign)

This the signature of `createCampaign`:

```
public function createCampaign(
    string $fromName,
    string $replyTo,
    string $subject,
    string $html = '',
    string $listName = '',
    array $options = [],
    array $contentOptions = [])
```

Note the campaign will only be created, no mails will be sent out.

### Handling errors

[](#handling-errors)

If something went wrong you can get the last error with:

```
Newsletter::getLastError();
```

If you just want to make sure if the last action succeeded you can use:

```
Newsletter::lastActionSucceeded(); //returns a boolean
```

### Need something else?

[](#need-something-else)

If you need more functionality you get an instance of the underlying [MailChimp Api](https://github.com/drewm/mailchimp-api) with:

```
$api = Newsletter::getApi();
```

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

### Changelog

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

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

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

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

[](#support-us)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie). All pledges will 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

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% 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 ~37 days

Recently: every ~60 days

Total

29

Last Release

2986d 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

PHP version history (4 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

### Community

Maintainers

![](https://www.gravatar.com/avatar/add214fc5f7951e2812c73d32a7aa050d15def735fa8302c492fa47bfa252242?d=identicon)[Thedigit](/maintainers/Thedigit)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (133 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (9 commits)")[![lartisan](https://avatars.githubusercontent.com/u/7920412?v=4)](https://github.com/lartisan "lartisan (5 commits)")[![drbyte](https://avatars.githubusercontent.com/u/404472?v=4)](https://github.com/drbyte "drbyte (3 commits)")[![Thedigit](https://avatars.githubusercontent.com/u/2549321?v=4)](https://github.com/Thedigit "Thedigit (2 commits)")[![d-jimenez](https://avatars.githubusercontent.com/u/74740646?v=4)](https://github.com/d-jimenez "d-jimenez (2 commits)")[![arondeparon](https://avatars.githubusercontent.com/u/7697?v=4)](https://github.com/arondeparon "arondeparon (2 commits)")[![juukie](https://avatars.githubusercontent.com/u/2678657?v=4)](https://github.com/juukie "juukie (1 commits)")[![Omranic](https://avatars.githubusercontent.com/u/406705?v=4)](https://github.com/Omranic "Omranic (1 commits)")[![pdbreen](https://avatars.githubusercontent.com/u/1670907?v=4)](https://github.com/pdbreen "pdbreen (1 commits)")[![pixelpeter](https://avatars.githubusercontent.com/u/6502630?v=4)](https://github.com/pixelpeter "pixelpeter (1 commits)")[![remkobrenters](https://avatars.githubusercontent.com/u/4686406?v=4)](https://github.com/remkobrenters "remkobrenters (1 commits)")[![robindirksen1](https://avatars.githubusercontent.com/u/22446895?v=4)](https://github.com/robindirksen1 "robindirksen1 (1 commits)")[![tomcoonen](https://avatars.githubusercontent.com/u/988013?v=4)](https://github.com/tomcoonen "tomcoonen (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")[![Yugis](https://avatars.githubusercontent.com/u/14917669?v=4)](https://github.com/Yugis "Yugis (1 commits)")[![amosmos](https://avatars.githubusercontent.com/u/2318695?v=4)](https://github.com/amosmos "amosmos (1 commits)")[![carlos-ea](https://avatars.githubusercontent.com/u/5512089?v=4)](https://github.com/carlos-ea "carlos-ea (1 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![filisko](https://avatars.githubusercontent.com/u/8798694?v=4)](https://github.com/filisko "filisko (1 commits)")

---

Tags

laravelmailchimpnewsletter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thedigit-laravel57-newsletter/health.svg)

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

###  Alternatives

[spatie/laravel-newsletter

Manage Mailcoach and MailChimp newsletters in Laravel

1.6k6.3M26](/packages/spatie-laravel-newsletter)[tzsk/sms

A robust and unified SMS gateway integration package for Laravel, supporting multiple providers.

320244.3k6](/packages/tzsk-sms)[therobfonz/laravel-mandrill-driver

Mandrill Driver for Laravel

773.5M](/packages/therobfonz-laravel-mandrill-driver)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[salamwaddah/laravel-mandrill-driver

Mandrill notification channel for Laravel 5, 6, 7, 8, 9, 10, 11, 12

1174.3k](/packages/salamwaddah-laravel-mandrill-driver)

PHPackages © 2026

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