To connect your Laravel website with Mailchimp, you can use the Laravel Mailchimp package.
Here are the steps to connect Mailchimp with your Laravel website:
Install the Laravel Mailchimp package:
composer require sathru/mailchimp-laravel
Add the Mailchimp API key to your .env
file:
MAILCHIMP_API_KEY=your-api-key
Add the Mailchimp service provider to the config/app.php
file:
Sathru\Mailchimp\MailchimpServiceProvider::class,
Add the Mailchimp facade to the config/app.php
file:
'Mailchimp' => Sathru\Mailchimp\Facades\Mailchimp::class,
Publish the config file:
php artisan vendor:publish --provider="Sathru\Mailchimp\MailchimpServiceProvider"
Use the Mailchimp API in your Laravel application:
You can use the Mailchimp API in your Laravel application by calling the API methods on the Mailchimp
facade. For example:
$listId = 'your-list-id'; $subscriberEmail = 'subscriber@example.com'; Mailchimp::subscribe($listId, ['email' => $subscriberEmail]);