PHPackages                             nztim/mailchimp - 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. [API Development](/categories/api)
4. /
5. nztim/mailchimp

ActiveLibrary[API Development](/categories/api)

nztim/mailchimp
===============

Mailchimp API wrapper, includes Laravel 5 support.

v6.1(8mo ago)991.2M↓18.4%243MITPHPPHP ^8.4

Since Jun 24Pushed 8mo ago6 watchersCompare

[ Source](https://github.com/nztim/mailchimp)[ Packagist](https://packagist.org/packages/nztim/mailchimp)[ RSS](/packages/nztim-mailchimp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (33)Used By (3)

Mailchimp
=========

[](#mailchimp)

Basic abstraction with Laravel integration for Mailchimp API v3

### Installation

[](#installation)

- `composer require nztim/mailchimp`
- For Laravel support:
    - Laravel 5.5+ will auto-discover the package, for earlier versions you will need to:
        - Add the service provider to `config/app.php`: `NZTim\Mailchimp\MailchimpServiceProvider::class,`
        - Register the facade: `'Mailchimp' => NZTim\Mailchimp\MailchimpFacade::class,`
    - Add an `.env` value for `MC_KEY` (your API key)
    - Optionally, publish the config file:
        - `php artisan vendor:publish --provider=NZTim\Mailchimp\MailchimpServiceProvider`

### Usage

[](#usage)

- Within Laravel 5, use the `Mailchimp` facade or inject `NZTim\Mailchimp\Mailchimp` using the container.
- Alternatively, instantiate using the API key: `$mc = new NZTim\Mailchimp\Mailchimp($apikey)`

```
// Get an array of all available lists:
Mailchimp::getLists();

// Get lists with parameters - get IDs of lists a user is subscribed to:
Mailchimp::getLists(['email' => 'user@example.com', 'fields' => 'lists.id']);

// Check to see if an email address is subscribed to a list:
Mailchimp::check($listId, $emailAddress); // Returns boolean

// Check the staus of a subscriber:
Mailchimp::status($listId, $emailAddress); // Returns 'subscribed', 'unsubscribed', 'cleaned', 'pending', 'transactional' or 'not found'

// Get subscriber tags:
Mailchimp::getTags($listId, $emailAddress); // Returns array of Tag objects

// Add tags to a subscriber
Mailchimp::addTags($listId, $emailAddress, $tags); // $tags = ['tag1', 'tag2']

// Remove tags from a subscriber
Mailchimp::removeTags($listId, $emailAddress, $tags); // $tags = ['tag1', 'tag2']

// Remove all tags from a subscriber
Mailchimp::removeAllTags($listId, $emailAddress);

// Adds/updates an existing subscriber:
Mailchimp::subscribe($listId, $emailAddress, $merge = [], $confirm = true);
// Use $confirm = false to skip double-opt-in if you already have permission.
// This method will update an existing subscriber and will not ask an existing subscriber to re-confirm.

// Unsubscribe a member (set status to 'unsubscribed'):
Mailchimp::unsubscribe($listId, $emailAddress);

// Archive a member (no longer counts towards audience limits):
Mailchimp::archive($listId, $emailAddress);

// Permanently delete a member record:
Mailchimp::delete($listId, $emailAddress);
// Use with care: deleted members cannot be re-added without the user subscribing via a Mailchimp-hosted form with double-opt-in confirmation.

// Directly call the API:
Mailchimp::api($method, $endpoint, $data = []); // Returns an array.
```

For access to all the member properties available in the v3 API, use the Member class to subscribe and update list members:

```
$member = (new NZTim\Mailchimp\Member($email))
    ->merge_fields(['FNAME' => 'First name'])
    ->email_type('text')
    ->confirm(false);
Mailchimp::addUpdateMember($listId, $member);
```

As with the `subscribe()` method, double-opt-in is default but existing members will not be asked to re-verify so you can use the same methods for create and update without needing to check.

### Errors

[](#errors)

- Exceptions are thrown for all errors.
- Networking/communications errors will usually be of the type `ConnectionException`.
- API errors will be of the base type `NZTim\Mailchimp\MailchimpException`, e.g. incorrect API key, list does not exist.
- `NZTim\Mailchimp\Exception\MailchimpBadRequestException` includes a `response()` method that attempts to provide the response body as an array, for automated handling of some error types.
- Gotchas with merge fields:
    - If you receive an error adding a new subscriber, check for required merge fields.
    - Merge fields are case-sensitive.
    - `Mailchimp::addUpdateMemberSkipMergeValidation()` is available if needed.

### Examples

[](#examples)

```
// Laravel:
// Subscribe a user to your list, existing subscribers will not receive confirmation emails
Mailchimp::subscribe('listid', 'user@domain.com');

// Subscribe a user to your list with merge fields and double-opt-in confirmation disabled
Mailchimp::subscribe('listid', 'user@domain.com', ['FNAME' => 'First name', 'LNAME' => 'Last name'], false);

// Subscribe/update a user using the Member class
$member = (new NZTim\Mailchimp\Member($email))->interests(['abc123fed' => true])->language('th');
Mailchimp::addUpdateMember('listid', $member);
```

### Upgrading

[](#upgrading)

- To v6.0: PHP 8.4 is required
- To v5.0: PHP 8.1 is required
- To v4.0:
    - PHP 7.4 | 8.0 is now required
    - Use unsub with archive in order to maximise the use of free accounts.
- To v3.0:
    - Exceptions are now thrown for all errors, use try/catch where necessary
    - Double-opt-in is now the default, update `Mailchimp::subscribe()` as required

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance62

Regular maintenance activity

Popularity55

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity92

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95% 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 ~120 days

Recently: every ~196 days

Total

32

Last Release

241d ago

Major Versions

v1.0 → v2.02016-01-25

v2.2 → v3.02017-01-11

v3.11 → v4.02020-12-28

v4.5 → v5.02023-04-06

v5.4 → v6.02025-08-31

PHP version history (4 changes)v2.0PHP &gt;=7.0.0

v4.0PHP ^7.4 || ^8

v5.0PHP ^8.1

v6.0PHP ^8.4

### Community

Maintainers

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

---

Top Contributors

[![nztim](https://avatars.githubusercontent.com/u/3453450?v=4)](https://github.com/nztim "nztim (57 commits)")[![IlyasMakari](https://avatars.githubusercontent.com/u/21266386?v=4)](https://github.com/IlyasMakari "IlyasMakari (1 commits)")[![krve](https://avatars.githubusercontent.com/u/5139119?v=4)](https://github.com/krve "krve (1 commits)")[![Omegatcu](https://avatars.githubusercontent.com/u/858438?v=4)](https://github.com/Omegatcu "Omegatcu (1 commits)")

---

Tags

laravelmailchimpmailchimp-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nztim-mailchimp/health.svg)

```
[![Health](https://phpackages.com/badges/nztim-mailchimp/health.svg)](https://phpackages.com/packages/nztim-mailchimp)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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