Mailchimp Newsletters

Mailchimp Newsletters

To use the prebuilt handler or trait to send newsletter submissions to Mailchimp, you will need to install the spatie/laravel-newsletter package.

Default Handler

To send newsletter submissions forms to mailchimp, you can use or customise the provided Yadda\Enso\Newsletter\Handlers\MailchimpHandler.

By default, this assumes the form will submit an email, first_name and last_name.

It will subscribe or update an existing subscription for the given email, passing first_name and last_name as merge tags FNAME and LNAME, as per a vanilla mailchimp setup.

On failure, it returns either a json response with a 'message' property set to the Mailchimp Error that occured, or will redirect back with a message of the Mailchimp error, depending on whether the request was made via xhr or not.

Customization

You can alter merge tags, you should override the mailchimpMergeData to return alternative merge data.

You can alter the error handling by overriding the mailchimpFailureResponse function.

If you need to create a handler that performs this along with other actions, there is a trait which provides basic framework for this handler Yadda\Enso\Newsletter\Traits\SendNewsletterToMailchimp.