PHPackages                             sensson/laravel-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. [Mail &amp; Notifications](/categories/mail)
4. /
5. sensson/laravel-mailchimp

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

sensson/laravel-mailchimp
=========================

A simple Mailchimp implementation with OAuth2

v0.2.0(1mo ago)0389↓53.6%MITPHPPHP ^8.3CI passing

Since Feb 26Pushed 4d agoCompare

[ Source](https://github.com/sensson/laravel-mailchimp)[ Packagist](https://packagist.org/packages/sensson/laravel-mailchimp)[ Docs](https://github.com/sensson/laravel-mailchimp)[ GitHub Sponsors](https://github.com/Sensson)[ RSS](/packages/sensson-laravel-mailchimp/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (49)Versions (8)Used By (0)

Laravel Mailchimp
=================

[](#laravel-mailchimp)

[![Latest Version on Packagist](https://camo.githubusercontent.com/90f0a760bbc8466c8676035f698a35fd24af12c4142d5315b6a39fb83c73b82b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656e73736f6e2f6c61726176656c2d6d61696c6368696d702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sensson/laravel-mailchimp)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f9d10bfde2bd442cc33f8beb6786c635838eb2571dd1ffa1ccf9d73a393c103e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73656e73736f6e2f6c61726176656c2d6d61696c6368696d702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sensson/laravel-mailchimp/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/02146ef8061d89fec4b2b8c2774a07829ebb45b3cab48f93bef5ac310fdbc39e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73656e73736f6e2f6c61726176656c2d6d61696c6368696d702f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/sensson/laravel-mailchimp/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/36d66eb4f131eb5fa737a1dd10eb24cace7ed6044b2b0f9508e53ea954dee8aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656e73736f6e2f6c61726176656c2d6d61696c6368696d702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sensson/laravel-mailchimp)

A Laravel package for the Mailchimp Marketing API with OAuth 2.0 support, built on [SaloonPHP](https://docs.saloon.dev).

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

[](#installation)

```
composer require sensson/laravel-mailchimp
```

Publish the config file:

```
php artisan vendor:publish --tag="mailchimp-config"
```

Add your OAuth credentials to `.env`. You can create an OAuth app in [your Mailchimp account](https://admin.mailchimp.com/account/oauth2/) under **Registered Apps**:

```
MAILCHIMP_CLIENT_ID=your-client-id
MAILCHIMP_CLIENT_SECRET=your-client-secret
MAILCHIMP_REDIRECT_URI=https://your-app.com/mailchimp/callback
```

OAuth 2.0
---------

[](#oauth-20)

Redirect the user to Mailchimp to authorize your app:

```
use Sensson\Mailchimp\Facades\Mailchimp;

return redirect()->to(Mailchimp::auth()->getAuthorizationUrl());
```

Handle the callback to get an access token and data center:

```
use Sensson\Mailchimp\Enums\ServerPrefix;

$token = Mailchimp::auth()->exchangeToken($request->code);
$metadata = Mailchimp::auth()->getMetadata($token);
$dc = ServerPrefix::from($metadata->json('dc'));
```

Store `$token` and `$dc` for later use. The `MailchimpAuth` cast makes this easy on any Eloquent model:

```
use Sensson\Mailchimp\Casts\MailchimpAuth;

protected $casts = [
    'mailchimp' => MailchimpAuth::class,
];
```

```
use Sensson\Mailchimp\Data\MailchimpToken;

$user->mailchimp = new MailchimpToken(accessToken: $token, serverPrefix: $dc);
$user->save();
```

Usage
-----

[](#usage)

```
use Sensson\Mailchimp\Facades\Mailchimp;

$mailchimp = Mailchimp::make($user->mailchimp->serverPrefix, $user->mailchimp->accessToken);
```

### Audiences

[](#audiences)

```
$audiences = $mailchimp->audiences()->all();

$audience = $mailchimp->audiences()->get('list-id');
```

### Members

[](#members)

```
use Sensson\Mailchimp\Data\Member;
use Sensson\Mailchimp\Enums\MemberStatus;

$members = $mailchimp->members('list-id')->all(count: 50, offset: 0);

$member = $mailchimp->members('list-id')->get($subscriberHash);
```

Create or update a member:

```
$member = new Member(
    email_address: 'john@example.com',
    status: MemberStatus::Subscribed,
    merge_fields: ['FNAME' => 'John', 'LNAME' => 'Doe'],
);

$mailchimp->members('list-id')->createOrUpdate($member);
```

Mailchimp blocks subscribing addresses that have previously unsubscribed, bounced, or been forgotten. These surface as typed exceptions so you can react without inspecting the response body:

```
use Sensson\Mailchimp\Exceptions\ForgottenEmailNotSubscribedException;
use Sensson\Mailchimp\Exceptions\MemberInComplianceStateException;

try {
    $mailchimp->members('list-id')->createOrUpdate($member);
} catch (MemberInComplianceStateException|ForgottenEmailNotSubscribedException) {
    // member is permanently unreachable — the contact must resubscribe themselves
}
```

Archive a member:

```
$hash = md5(strtolower('john@example.com'));

$mailchimp->members('list-id')->archive($hash);
```

Batch subscribe multiple members at once:

```
$members = [
    new Member(email_address: 'john@example.com', status: MemberStatus::Subscribed),
    new Member(email_address: 'jane@example.com', status: MemberStatus::Subscribed),
];

$mailchimp->members('list-id')->batch($members);
```

Tag and untag members:

```
$hash = md5(strtolower('john@example.com'));

$mailchimp->members('list-id')->tag($hash, ['VIP', 'Early Adopter']);
$mailchimp->members('list-id')->untag($hash, ['VIP']);
```

### Merge Fields

[](#merge-fields)

```
$fields = $mailchimp->mergeFields('list-id')->all();
```

### Webhooks

[](#webhooks)

```
use Sensson\Mailchimp\Enums\WebhookEvent;
use Sensson\Mailchimp\Enums\WebhookSource;

$webhooks = $mailchimp->webhooks('list-id')->all();

$webhook = $mailchimp->webhooks('list-id')->create(
    'https://example.com/webhook',
    [WebhookEvent::Subscribe, WebhookEvent::Unsubscribe],
    [WebhookSource::User, WebhookSource::Admin],
);

$mailchimp->webhooks('list-id')->delete($webhook->id);
```

Testing
-------

[](#testing)

Use `fake()` and `authFake()` with Saloon's `MockClient`:

```
use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;
use Sensson\Mailchimp\Facades\Mailchimp;
use Sensson\Mailchimp\Requests\Audiences\ListAudiences;

$mock = new MockClient([
    ListAudiences::class => MockResponse::make([
        'lists' => [
            ['id' => 'abc123', 'name' => 'Newsletter', 'member_count' => 100],
        ],
    ]),
]);

Mailchimp::fake($mock);

$audiences = Mailchimp::audiences()->all();

$mock->assertSent(ListAudiences::class);
```

Run the test suite:

```
composer test
```

Changelog
---------

[](#changelog)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Sensson](https://github.com/sensson)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance95

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.1% 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 ~25 days

Total

4

Last Release

52d ago

### Community

Maintainers

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

---

Top Contributors

[![ju5t](https://avatars.githubusercontent.com/u/3635751?v=4)](https://github.com/ju5t "ju5t (31 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelSenssonlaravel-mailchimp

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1123.7k](/packages/codebar-ag-laravel-docuware)[vormkracht10/laravel-mails

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

24857.5k](/packages/vormkracht10-laravel-mails)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[redberry/mailbox-for-laravel

This is my package mailbox-for-laravel

4115.7k](/packages/redberry-mailbox-for-laravel)[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

8120.4k](/packages/danestves-laravel-polar)

PHPackages © 2026

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