Search by

jeffersongoncalves / laravel-mailchimp

jeffersongoncalves

Laravel wrapper for Mailchimp Marketing API v3

Package info

github.com/jeffersongoncalves/laravel-mailchimp

pkg:composer/jeffersongoncalves/laravel-mailchimp

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-09-07 20:57 UTC

This package is auto-updated.

Last update: 2026-09-07 20:57:34 UTC


README

Laravel Mailchimp

Laravel Mailchimp

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads License

A Laravel wrapper for the Mailchimp Marketing API v3. Covers lists, members, campaigns, reports and automations through a simple, typed API built on Laravel's Http client.

Features

  • Lists: list, get
  • Members: list, add, update
  • Campaigns: list, get, create, send
  • Reports: get
  • Automations: list
  • Datacenter is derived automatically from the API key suffix (e.g. xxxx-us21us21)
  • Throws MailchimpException (with the original API error body) on any non-2xx response

Installation

You can install the package via composer:

composer require jeffersongoncalves/laravel-mailchimp

Publish the config file:

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

Set your Mailchimp API key in .env:

MAILCHIMP_API_KEY=your-api-key-us21

Find (or generate) your API key under Account > Extras > API keys.

Configuration

// config/mailchimp.php
return [
    'api_key' => env('MAILCHIMP_API_KEY', ''),
];

Usage

The package is resolved via the Mailchimp facade or by injecting JeffersonGoncalves\Mailchimp\Mailchimp. Each resource is exposed as a method returning a dedicated resource class.

Lists

use JeffersonGoncalves\Mailchimp\Facades\Mailchimp;

$lists = Mailchimp::lists()->list(count: 10, offset: 0);

$list = Mailchimp::lists()->get('abc123');

Members

$members = Mailchimp::members()->list('abc123', count: 10, offset: 0, status: 'subscribed');

Mailchimp::members()->add(
    listId: 'abc123',
    email: 'jane@example.com',
    status: 'subscribed',
    firstName: 'Jane',
    lastName: 'Doe',
    tags: ['vip'],
);

Mailchimp::members()->update(
    listId: 'abc123',
    subscriberHash: md5(strtolower('jane@example.com')),
    status: 'unsubscribed',
);

Campaigns

$campaigns = Mailchimp::campaigns()->list(count: 10, offset: 0, status: 'sent', type: 'regular');

$campaign = Mailchimp::campaigns()->get('c1');

Mailchimp::campaigns()->create(
    listId: 'abc123',
    type: 'regular',
    subject: 'Hello!',
    fromName: 'Jane',
    replyTo: 'jane@example.com',
    title: 'Welcome campaign',
);

Mailchimp::campaigns()->send('c1');

Reports

$report = Mailchimp::reports()->get('c1');

Automations

$automations = Mailchimp::automations()->list(count: 10, offset: 0);

Error handling

Any non-2xx API response throws JeffersonGoncalves\Mailchimp\Exceptions\MailchimpException, which exposes the decoded error body:

use JeffersonGoncalves\Mailchimp\Exceptions\MailchimpException;

try {
    Mailchimp::campaigns()->send('c1');
} catch (MailchimpException $e) {
    logger()->error($e->getMessage(), $e->errorBody());
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.