Mailchimp API v3 wrapper, includes Laravel support.
Basic abstraction with Laravel integration for Mailchimp API v3
composer require nztim/mailchimpconfig/app.php: NZTim\Mailchimp\MailchimpServiceProvider::class,'Mailchimp' => NZTim\Mailchimp\MailchimpFacade::class,.env value for MC_KEY (your API key)php artisan vendor:publish --provider=NZTim\Mailchimp\MailchimpServiceProviderMailchimp facade or inject NZTim\Mailchimp\Mailchimp using the container.$mc = new NZTim\Mailchimp\Mailchimp($apikey)…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.
ConnectionException.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.Mailchimp::addUpdateMemberSkipMergeValidation() is available if needed.// Laravel:
// Subscribe a user to your list, existing subscribers will not receive confirmation emails
Mailchimp::subscribe('listid', '[email protected]');
// Subscribe a user to your list with merge fields and double-opt-in confirmation disabled
Mailchimp::subscribe('listid', '[email protected]', ['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);Mailchimp::subscribe() as requiredNo open issues yet, or sync has not completed.