Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

Easily integrate MailChimp in Laravel 5

Today we released a new major version of our laravel-newsletter package. This package makes it easy to integrate MailChimp in your Laravel app. Under the hood V3 of the MailChimp API is used. If you’re used the older version of our package be sure to upgrade by the end of this year: MailChimp will shut down V2 of their API.

Here are a few examples what you can do with it:

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

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

//Merge variables can be passed as the second argument
Newsletter::subscribe('[email protected]', ['firstName'=>'Sam', 'lastName'=>'Vines']);

//Subscribe someone to a specific list by using the third argument:
Newsletter::subscribe('[email protected]', ['firstName'=>'Nanny', 'lastName'=>'Ogg'], 'Name of your list');

//Get some member info, returns an array described in the official docs
Newsletter::getMember('[email protected]');

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

//If you want to do something else, you can get an instance of the underlying API:

There are a few additional methods available. If you need to handle multiple lists, the package can handle that for you as well. Head over to the documentation of the package on GitHub to learn all the options. If you like it, be sure to check out our other packages.

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band. He loves waffles and butterflies.
  • Stefan Braun Braun

    Hey Freek. I am playing around with your newsletter package. What’s the best way to get all subscribed members from mailchimp ? Is there something out of the box in this package ?

  • Bruno Justino Praciano

    @freekmurze:disqus Can I disable Optin of mailchimp?

  • smith

    why mail chimp..why cant we use the laravel email service?

  • Abu Zofar Mohammad Moslehuddin

    Mega tutorials with Videos and Source Code.