spatie / laravel-newsletter

Manage Mailcoach and MailChimp newsletters in Laravel
https://freek.dev/440-easily-integrate-mailchimp-in-laravel-5
MIT License
1.61k stars 235 forks source link

Why error subscribing to specific mailchimp list #194

Closed sergeynilov closed 5 years ago

sergeynilov commented 5 years ago

Hello, In my laravel 5.7 app I make subscribe/unsubscribe to lists of mailchimp using https://github.com/spatie/laravel-newsletter It works when ok and all users are suscribed to the current mailchimp list, which is described in .env file

MAILCHIMP_APIKEY = NNNNNNNNNN
MAILCHIMP_LIST_ID = NNNNNNNNNN  # ID of 'subscribers' mailchimp list

But as my site has several group news I try subscribe to mailchimp list with code : $retData= Newsletter::subscribe($userProfile->email, ['FNAME'=>$userProfile->first_name, 'LNAME'=>$userProfile->last_name], 'subscribers'); // 3rd parameter can be different where 3rd parameter is mailchimp list name, as I see it on the server as : https://prnt.sc/mqbgnb But I got error : There is no list namedsubscribers. Why error? Misconfiguring of of this mailchimp list ? It has some options, I am not sure if some of them is related to my issue ?

In doc I read as :

//Subscribe someone to a specific list by using the third argument: Newsletter::subscribe('nanny.ogg@discworld.com', ['firstName'=>'Nanny', 'lastName'=>'Ogg'], 'Name of your list');

How to fix my error ?

Thanks!

sergeynilov commented 5 years ago

Sorry, I still search for decision...

delenamalan commented 5 years ago

You can add more lists in your config/newsletter.php file.

There is an array called lists to which you can your different newsletters, for example:

    /*
     * Here you can define properties of the lists.
     */
    'lists' => [
        'list_name1' => [
            'id' => env('MAILCHIMP_LIST_ID1'),
        ],
        'list_name2' => [
            'id' => env('MAILCHIMP_LIST_ID2'),
        ],
    ],
twf-nikhila commented 5 years ago

@delenamalan @freekmurze Is there a way to directly provide list id value when subscribing a user instead of adding it in the config file?