It subscribes an email address to your mailchimp list.
This package can be used as a stand-alone package with any PHP framework or as a Laravel package.
composer require mabasic/mailchimp
First, add this to your config/services.php
file:
'mailchimp' => [
'key' => env('MAILCHIMP_KEY'),
'dc' => env('MAILCHIMP_DATA_CENTER', 'us1')
]
Hint! You can even add your
list_id
above if you only use one list in your application.
Then, add the correct values in your .env
file:
MAILCHIMP_KEY=
MAILCHIMP_DATA_CENTER=
Finally, do this to subscribe an address:
use Mabasic\Mailchimp\Facade as Mailchimp;
Mailchimp::subscribeAnAddress($list_id, $email);
$mailchimp = new \Mabasic\Mailchimp\Mailchimp($key, $dc);
$mailchimp->subscribeAnAddress($list_id, $email);
Read the source code for src/Mailchimp.php
to better understand what $dc
does and how to subscribe an address without a confirmation email. It is very educational.
I would like to extend my thanks to the following sponsors & backers for funding my open-source journey. If you are interested in becoming a sponsor or backer, please visit the Laravelista Backers page.
Thank you for considering contributing to mabasic/mailchimp! The contribution guide can be found on the Laravelista website.
In order to ensure that the Laravelista community is welcoming to all, please review and abide by the Code of Conduct.
mabasic/mailchimp is open-source software licensed under the MIT license.