GithubHelp home page GithubHelp logo

spatie / laravel-newsletter Goto Github PK

View Code? Open in Web Editor NEW
1.6K 41.0 232.0 259 KB

Manage Mailcoach and MailChimp newsletters in Laravel

Home Page: https://freek.dev/440-easily-integrate-mailchimp-in-laravel-5

License: MIT License

PHP 100.00%
laravel php newsletter mailchimp mailchimp-api mailcoach

laravel-newsletter's People

Contributors

adrianmrn avatar aerni avatar akoepcke avatar amosmos avatar arondeparon avatar carlos-ea avatar d-jimenez avatar dependabot[bot] avatar drbyte avatar estharian avatar freekmurze avatar fridzema avatar jasonmccreary avatar jose-bittacora avatar juukie avatar laravel-shift avatar lartisan avatar nielsvanpach avatar pdbreen avatar pixelpeter avatar remkobrenters avatar riasvdv avatar robindirksen1 avatar rubenvanassche avatar sebastiandedeyne avatar sebdesign avatar shuvroroy avatar tomcoonen avatar twf-nikhila avatar yugis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-newsletter's Issues

Can't catch AlreadySubscribed

Code below seems to trow an error when someone is already subscribed... Any idea how to solve?

try { Newsletter::subscribe($data['email'], ['firstName'=>$data['firstname'], 'lastName'=>$data['lastname']], 'subscribers'); } catch (Exception $e) { ... }

schermafbeelding 2016-02-16 om 20 20 47

schermafbeelding 2016-02-16 om 20 28 51

Non-static method Spatie\Newsletter\MailChimp\Newsletter::subscribe() should not be called statically

Hi,

I've recently upgraded to Laravel 5.2 and I've noticed the following errors appearing.

Non-static method Spatie\Newsletter\MailChimp\Newsletter::subscribe() should not be called statically

I'm referencing the Newsletter with the following at the top of my controller:

use Spatie\Newsletter\MailChimp\Newsletter;

And it was working ok previously. Are the methods no longer defined as static? Any idea what could be causing this? Many thanks for your help

SSL Certificate Problem

Spatie\Newsletter\Exceptions\ServiceRefusedSubscription: API call to lists/subscribe failed: SSL certificate problem: unable to get local issuer certificate in

This problem started happening very suddenly. I'm running Ubuntu 14.04 on Forge. I tried adding the CA Cert to my SSL directory to no avail:

/etc/ssl/certs$ sudo wget http://curl.haxx.se/ca/cacert.pem

I restarted nginx after doing this. Still nothing.

This website http://redwebturtle.blogspot.nl/2013/09/mailchimp-api-v20-ssl-error-solution.html is suggesting editing curl options but that feels like a bad idea:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Any suggestions?

Sending campaign

After creating a campaign how would one send it? There's nothing in the docs outlining this, can you help please :)

Typo in documentation

Small typo in the documentation, Newsletter::lastActionSucceed() should be Newsletter::lastActionSucceeded()

Post Vs. Put

Hi,

Thank you for your quality work!
On my next project, I'm giving a try to your package. I usually used drew/mailchimp-api package.

/**
     * @param string $email
     * @param array  $mergeFields
     * @param string $listName
     * @param array  $options
     *
     * @return array|bool
     *
     * @throws \Spatie\Newsletter\Exceptions\InvalidNewsletterList
     */
    public function subscribe($email, $mergeFields = [], $listName = '', $options = [])
    {
        $list = $this->lists->findByName($listName);
        $defaultOptions = [
            'email_address' => $email,
            'status' => 'subscribed',
            'email_type' => 'html',
        ];
        if (count($mergeFields)) {
            $defaultOptions['merge_fields'] = $mergeFields;
        }
        $options = array_merge($defaultOptions, $options);
        $response = $this->mailChimp->post("lists/{$list->getId()}/members", $options);
        if (! $this->lastActionSucceeded()) {
            return false;
        }
        return $response;
    }

I always use something like:

$mailchimp->put("lists/$list/members/" . $mailchimp->subscriberHash($email), $args);

It has the benefit of updating a user if he is already subscribed. Post doesn't (if I'm not wrong).

Would you consider to switch to put instead or to introduce a new method such as subscribeOrUpdate()?

For instance, it can be very useful for "groups". A user can subscribe trough several forms and will be added/updated to several MC groups. Hence why the use of put is very handy.

Cheers

Language subriber

How can I pass along parameters to define the user's language preference inside the Subscribe function?

Question - multiple lists

How does one use this awesome tool with multiple lists? I have more than 1 list id like to use it on.

My setup is not working cant find the issue

I do really know what i did wrong i cant catch errors and such i dont have the expecience i entered the right api_key from my mailchimp and id_list in the config/laravel-newsletter.php file but still dont work....

My blade


<div class="row">
            <div class="col-md-5">
                <div class="well">
                    {{ Form::open(['route'=>['sendMail'], 'method'=>'POST']) }}
                    <div>
                        <h3 class="text-center">Subscribe Your Email</h3>
                        <input class="form-control" name="email" id="email" type="email" placeholder="Your Email" required>
                        <br/>
                        <div class="text-center">
                            <button class="btn btn-info btn-lg" type="submit">Subscribe</button>
                        </div>
                    </div>
                    {{ Form::close() }}
                </div>
            </div>
        </div>

Controller

use Newsletter;

public function subscribe(){

        return view('pages.subscribe');
    }

    public function sendMail(Request $request){

        $email = $request->input('email');

        Newsletter::subscribe($email, 'subscribers');


        return view('pages.subscribe');
    }

Routes
Route::get('subscribe', 'PagesController@subscribe')->name('pages.subscribe'); Route::post('sendMail', 'PagesController@sendMail')->name('sendMail');

Subscribe function not working

When create a new subscription it shows this error:

Argument 1 passed to Spatie\Newsletter\MailChimp\Newsletter::__construct() must be an instance of Spatie\Newsletter\Interfaces\NewsletterCampaignInterface, none given,

This is my code in controller function

(new Newsletter)->subscribe($request->email,['firstName' => $request->firstName, 'lastName' => $request->lastName], '1ad0b4002b');

Help me please

Update subscriber behaviour

What happens when I try to subscribe a user, that is already subscribed? I would expect it to then simply update instead.

A few problems with list subscription

When subscribing a user that already exists in a different list I got the following error:
400: [email protected] is already a list member. Use PUT to insert or update list members.

In addition, using the following settings in laravel-newsletter
'subscribe' => [
'emailType' => 'html',
'requireDoubleOptin' => true,
'updateExistingUser' => true,
],

didn't result in an double optin mail being send?
These seemed to work fine in the previous version. Any ideas?

lastActionSucceeded is always false after subscribing

Hi,

When I subscribe someone to a list, I want to check if it was successful.
But no matter what method I use, the check always fails and my exception is thrown...
When I check the list @ MailChimp though, the address was in fact successfully subscribed.
With the unsubscribe method, the success methods do return true...
Maybe it's related to this drewm/mailchimp-api issue?

public function subscribe($firstName, $lastName, $email)
{
    if ($this->newsletter->hasMember($email)) {
        throw new EmailAlreadySubscribed("[{$email}] is already subscribed to the newsletter.");
    }

    $this->newsletter->subscribe($email, [
        'FNAME' => $firstName,
        'LNAME' => $lastName
    ]);

    if ( ! $this->newsletter->lastActionSucceeded()) {
        // This always gets called
        throw new FailedToSubscribe($this->newsletter->getLastError());
    }
}

I also tried ->getApi()->success() and ->hasMember($email)...

Double API calls when trying to catch Exception from unsubscribe method

Hello,

First of all, thanks for your wrapper which is very convenient!

However, when I try to catch Exception from the unsubscribe method, 2 API calls are executed:

  • 1st call, the response is: n/a (the member is correctly unsubscribed)
  • 2nd call, the response is: (215) List_NotSubscribed (normal because the first one did the job)

Here is my piece of code :

    private function unsubscribeNewsletter($email){
       try {
            Newsletter::unsubscribe($email);
            return true;
        }catch (\Exception $e){
            Session::flash('message', "Une erreur s'est produite : ".$e->getMessage());
            return false;
        }
    }

And from my main method I call this private method like this:

       if(!$this->unsubscribeNewsletter($email)){
            return redirect()->back()->withInput();
        }
        // my work continue...

PS: I use this function only through a GET request (with the email in parameter)

To add further details, when I unsubscribe for the first time, only one API call is made (so it's ok). However, after registering again and trying to unsubscribe again, I get an Exception because 2 API calls are made... In addition, sometimes (rarely and randomly), I get the appropriate response (without 2 calls, so without Exception), even after subscribing / unsubscribing several times...

I don't really understand, maybe the problem is because my approach is not that good. In any case, it would be glad if you could help.

Thanks in advance.

Syntax error

Newsletter::createCampaign($subject, $contents, 'mySecondList); to Newsletter::createCampaign($subject, $contents, 'mySecondList');

PHP7 compatibility

First of all, thanks for this great piece of code, are you guys planning on implementing support for PHP7 (especially the issue with static calls to non-static methods).

Problem with multiple calls to hasMember

When making successive calls to hasMember (v3.0.2), I'm finding that the result will get stuck on false after the first proper false response.

I believe the problem has to do with the lastActionSucceeded() check after the lists->findByName() within getMember. Since no new API call was made, this check is out of place and returning the result of the prior API call which is no longer relevant to the current request.

    public function getMember($email, $listName = '')
    {
        $list = $this->lists->findByName($listName);

        if (!$this->lastActionSucceeded()) {
            return false;
        }

check if user subscribed a campaign

I currently use the default laravel user table, what's the best way to check if a user (can be identified by e-mail adress or object) is already in a campaign? So to let only users unsubscribe a newsletter in case of they subscribed it.

Call to undefined method App\Http\Controllers\MailchimpController::getMiddleware()

Hello,

I am using Laravel 5.2, Sentinel and "laravel-newsletter" package.

I installed and followed all the steps from the Readme, and configured the package but I am getting an error:

MalichimpController.php

namespace App\Http\Controllers;

use PHPUnit_Framework_TestCase;
use Spatie\Newsletter\NewsletterList;
use Newsletter;
use DrewM\MailChimp\MailChimp;
use Mockery;

class MailchimpController extends PHPUnit_Framework_TestCase
{
    protected $newsletterList;
    public function setUp()
    {
        parent::setUp();
        $this->newsletterList = new NewsletterList('subscriber', ['id' => 'abc123']);
    }

    public function it_can_determine_the_name_of_the_list()
    {
        $this->assertSame('subscriber', $this->newsletterList->getName());
    }

    public function it_can_determine_the_id_of_the_list()
    {
        $this->assertSame('abc123', $this->newsletterList->getId());
    }

    public function subscribe($email)
    {
        Newsletter::subscribe($email);
    }

    public function unSubscribe($email)
    {
        Newsletter::unsubscribe($email);
    }
}

Routes.php

Route::get('/subscribe/{email}', ['uses' => 'MailchimpController@subscribe', 'as' => 'subscribe']); 
Route::get('/unsubscribe/{email}', 'MailchimpController@unSubscribe'); 

So I run the url http://mysite.dev/subscribe/[email protected] and i get this Error

FatalErrorException in ControllerDispatcher.php line 110:
Call to undefined method App\Http\Controllers\MailchimpController::getMiddleware()

Any help would be appreciated.

Thank you

Subscribe method return false everytime

I have installed and configure API key and List ID but during below call:
Newsletter::subscribe($data['email'], [
'firstName' => $data['first_name'],
'lastName' => $data['last_name']
], 'subscribers');

I'm getting below false and when i print the dd($this->mailChimp->getLastResponse()); I'm getting below response:
array:2 [▼
"headers" => array:26 [▼
"url" => "https://us8.api.mailchimp.com/3.0/lists/1621af1908/members"
"content_type" => null
"http_code" => 0
"header_size" => 0
"request_size" => 0
"filetime" => -1
"ssl_verify_result" => 1
"redirect_count" => 0
"total_time" => 0.171
"namelookup_time" => 0.109
"connect_time" => 0.125
"pretransfer_time" => 0.0
"size_upload" => 0.0
"size_download" => 0.0
"speed_download" => 0.0
"speed_upload" => 0.0
"download_content_length" => -1.0
"upload_content_length" => -1.0
"starttransfer_time" => 0.0
"redirect_time" => 0.0
"redirect_url" => ""
"primary_ip" => "..."
"certinfo" => []
"primary_port" => 443
"local_ip" => "..."
"local_port" => 54676
]
"body" => false
]

Any one have idea what is the wrong with it ?

Thanks

Double opt-in

By default double opt-in is bypassed? I need to let users subscribe with double opt-in enabled. How can I achieve it?

Invalid MailChimp API key supplied

freshly installed and newly created list is giving me
there is nothing in my mailchimp column

Whoops, looks like something went wrong.

1/1
Exception in MailChimp.php line 39:
Invalid MailChimp API key supplied.

Class 'Newsletter' not found

I am having one issue and maybe this is nothing to do with your component or maybe it is. Any sort of suggestions I appreciated. This component works fine in my local computer. But when I execute Newsletter::subscribe() from server it says:

FatalErrorException in MySuperDuperController.php line 21:
Class 'Newsletter' not found

BTW: I have already told infrastructure engineer to run composer update and it didn't helped.

API key as variable

Hi there,

Is it possible to insert the API key as a variable to the config file? Now I have an application with one user. The API key is in the .env file. I want to expand my application so I can add more users. I have all settings (API key,...) of all users in a database.

Thanks,
Stijn

Certification problem

The library was working perfectly. Unfortunately, I receive the bellow exception. withouth any change in the code.

API call to lists/subscribe failed: SSL certificate problem: unable to get local issuer certificate.

Trying to get property of non-object when trying to subscribe

I'm getting this error when I'm trying to execute subscribe method.
Code that I'm trying to execute:

    public function subscribe() {
        $email = Input::get('email');

        if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false) {
            Newsletter::subscribe($email);
            return true;
        }

        return false;
    }

Error stack below:

ErrorException in NewsletterList.php line 37:
Trying to get property of non-object in NewsletterList.php line 37
at HandleExceptions->handleError('8', 'Trying to get property of non-object', 'D:\XAMPP\htdocs\mq\vendor\spatie\laravel-newsletter\src\MailChimp\NewsletterList.php', '37', array('email' => '[email protected]', 'listName' => '', 'listProperties' => array('id' => '', 'createCampaign' => array('fromEmail' => '', 'fromName' => '', 'toName' => ''), 'subscribe' => array('emailType' => 'html', 'requireDoubleOptin' => false, 'updateExistingUser' => false), 'unsubscribe' => array('deletePermanently' => false, 'sendGoodbyeEmail' => false, 'sendUnsubscribeEmail' => false)), 'emailType' => 'html', 'requireDoubleOptin' => false, 'updateExistingUser' => false)) in NewsletterList.php line 37
at NewsletterList->subscribe('[email protected]', '') in Newsletter.php line 49
at Newsletter->subscribe('[email protected]') in Facade.php line 210
at Facade::__callStatic('subscribe', array('[email protected]')) in NewsletterController.php line 95
at NewsletterFacade::subscribe('[email protected]') in NewsletterController.php line 95
at NewsletterController->subscribe()
at call_user_func_array(array(object(NewsletterController), 'subscribe'), array()) in Controller.php line 256
at Controller->callAction('subscribe', array()) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(NewsletterController), object(Route), 'subscribe') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(NewsletterController), object(Route), object(Request), 'subscribe') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\NewsletterController', 'subscribe') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54

Non-object access

hey @freekmurze, thanks for the library; however I'm stuck on this error

ErrorException in NewsletterList.php line 74:
Trying to get property of non-object

Because php $this->mailChimp = $app['laravel-newsletter-mailchimp']; is null. Any help?

Configuration load failing, somehow

I've just picked up a project for a new client and they have installed your package. All of the api keys and available configuration is fine -- from what I've gathered in the last 3 hours -- but for some reason your code is failing

Newsletter::subscribe('[email protected]', [], 'subscribers'); would throw no error
Newsletter::getMember('[email protected]', 'subscribers'); would of course return false

The issue is found by calling dd($lists) in the subscribe() function of your Newsletter class. The configuration is loaded by name with success but there is no id field present

NewsletterList {#147 ▼ +name: "subscribers" +properties: array:1 [▼ "id" => null ] }

Thoughts?

Merge Fields are wrong in Readme

I thought there was a problem but then after going to the mailchimp docs, i saw that first name is FNAME and last name is LNAME

Newsletter::subscribe('[email protected]', ['firstName'=>'Rince', 'lastName'=>'Wind']);

I don't know if you did this in purpose, like everybody just put the variables they want to send, but if not, you can save people some time by adding FNAME instead of firstName and LNAME instead of lastName in the Readme

Greetings!

Require Double opt in

Hi,

In version 2 it was possible to set a "require double opt-in" parameter. I can't find it in this (V3) release. Is it removed?

Newsletter::subscribe Unknown error, call getLastResponse() to find out what happened. error

@freekmurze thanks for the package

I am getting error while trying to subscribe an email
Unknown error, call getLastResponse() to find out what happened.

When I try to call getLastResponse() it throws error
Call to undefined method Spatie\Newsletter\Newsletter::getLastResponse()

Below is my controllers function and I've checked that $email is coming correctly:

   public function newsletterSubscription(Request $request) {
        $email = $request->get('email');
        Newsletter::subscribe($email);
        if (Newsletter::lastActionSucceeded()){
           return Redirect::back(); 
        }
        return Newsletter::getLastError();
    }

Please help!

Laravel 4.2 support

I currently have a project with L4, and would really like to use this package. I think that it shouldn't be a problem to make it compatible, just add another service provider.

Create .gitattributes

I was wondering. Maybe this project can use a .gitattributes file to exclude tests and stuff out off the composer installs.

@freekmurze what is your opinion? If you want i can create a PR for this.

Mailchimp_List_NotSubscribed?

I get this error when using Mailchimp subscribe function in a console

[Mailchimp_List_NotSubscribed]
The email address "[email protected]" does not belong to this list

I'm doing this:

foreach(User::all() as $user)
{
 Newsletter::subscribe($user->email, [], 'test_foobar');
        try {
            Newsletter::updateMember($user->email, [
                'MERGE1' => $user->name,
                'MERGE2' => $user->lastname,
            ], true, 'test_foobar');
     } catch (Exception $e) {

                }

But it returns [Mailchimp_List_NotSubscribed], and it doesn't go in the try-catch, it just fails..

Readme field names

It's super minor I know, but firstName and lastName should be FNAME and LNAME as those are the actual mergefield names MailChimp requires.

Trying to get property of non-object

After following the instructions, I'm stuck with this error

ErrorException in NewsletterList.php line 37: Trying to get property of non-object
I'm using Laravel 5.1.9

Thank you!

This is my main controller:

handleError('8', 'Trying to get property of non-object', '/home/vagrant/Code/jobnow/vendor/spatie/laravel-newsletter/src/MailChimp/NewsletterList.php', '37', array('email' => '[email protected]', 'mergeVars' => array(), 'listName' => '', 'listProperties' => array('id' => 'XXXXXXXXXX', 'createCampaign' => array('fromEmail' => '', 'fromName' => '', 'toName' => ''), 'subscribe' => array('emailType' => 'html', 'requireDoubleOptin' => false, 'updateExistingUser' => false), 'unsubscribe' => array('deletePermanently' => false, 'sendGoodbyeEmail' => false, 'sendUnsubscribeEmail' => false)), 'emailType' => 'html', 'requireDoubleOptin' => false, 'updateExistingUser' => false)) in NewsletterList.php line 37 at NewsletterList->subscribe('[email protected]', array(), '') in Newsletter.php line 49 at Newsletter->subscribe('[email protected]') in Facade.php line 210 at Facade::__callStatic('subscribe', array('[email protected]')) in mainController.php line 9 at NewsletterFacade::subscribe('[email protected]') in mainController.php line 9 at mainController->index() at call_user_func_array(array(object(mainController), 'index'), array()) in Controller.php line 256 at Controller->callAction('index', array()) in ControllerDispatcher.php line 164 at ControllerDispatcher->call(object(mainController), object(Route), 'index') in ControllerDispatcher.php line 112 at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114 at ControllerDispatcher->callWithinStack(object(mainController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 69 at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\mainController', 'index') in Route.php line 201 at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134 at Route->run(object(Request)) in Router.php line 704 at Router->Illuminate\Routing\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in Router.php line 706 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671 at Router->dispatchToRoute(object(Request)) in Router.php line 631 at Router->dispatch(object(Request)) in Kernel.php line 236 at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50 at VerifyCsrfToken->handle(object(Request), object(Closure)) at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54 at ShareErrorsFromSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62 at StartSession->handle(object(Request), object(Closure)) at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37 at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59 at EncryptCookies->handle(object(Request), object(Closure)) at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124 at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103 at Pipeline->then(object(Closure)) in Kernel.php line 122 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87 at Kernel->handle(object(Request)) in index.php line 54 ```

firstName and lastName ignored

When subscribing a user, I encounted a problem with the first and last name attributes being ignored.

By examining the mailchimp API, it was resolved using FNAME and LNAME like so:

Newsletter::subscribe('[email protected]', ['FNAME'=>'Rince', 'LNAME'=>'Wind']);

Update status to unsubscribe, instead of deleting the subscriber

When checking the base code, I noticed that the function performing the unsubscribing is deleting the current subscriber from the list, instead of updating its status. It is true that a subscriber unsubscribed by itself cannot be added back to the list, but not sure if it is a good practice to delete the subscriber, since its history won't preserve, and maybe some projects implementing this library would want to keep track of the history for its subscribing list. Also, if the subscriber is unsubscribed manually, it can be added back to the list, and its history will remain.

http://kb.mailchimp.com/lists/growth/requirements-and-best-practices-for-lists
http://kb.mailchimp.com/lists/managing-subscribers/how-to-remove-subscribers

The package does not post to my mailchimp account.

I have included my api_key and list id so everything works fine but when i post to my account or get subscriber info using
'''Newsletter::subscribe($email, ['firstName'=>'Nanny', 'lastName'=>'Ogg'],'subscribers') or Newsletter::getMember('[email protected]'). ''' I get no response. Thanks for your quick response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.