<commit_before>### Work in progress, do not include this package in your project yet...

# Manage newsletters in Laravel 5
[![Latest Version](https://img.shields.io/github/release/freekmurze/laravel-newsletter.svg?style=flat-square)](https://github.com/freekmurze/laravel-newsletter/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/freekmurze/laravel-newsletter/master.svg?style=flat-square)](https://travis-ci.org/freekmurze/laravel-newsletter)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/10993a65-449a-488a-886c-f810b9950070/mini.png)](https://insight.sensiolabs.com/projects/10993a65-449a-488a-886c-f810b9950070)
[![Quality Score](https://img.shields.io/scrutinizer/g/freekmurze/laravel-newsletter.svg?style=flat-square)](https://scrutinizer-ci.com/g/freekmurze/laravel-newsletter)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-newsletter.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-newsletter)

This package provides an easy way to integrate email marketing services with Laravel 5. Currently the package only supports MailChimp. In the future more services may get added.

## Installation

You can install this package via composer using:

```bash
composer require spatie/laravel-newsletter
```

You must also install this service provider.

```php

// config/app.php

'providers' => [
    ...
    'Spatie\Newsletter\NewsletterServiceProvider',
    ...
];
```

If you want to make use of the facade you must install it as well.

```php
// config/app.php
'aliases' => [
    ...
    'Newsletter' => 'Spatie\Newsletter\NewsletterFacade',
];
```

To publish the config file to ``app/config/laravel-newsletter.php`` run:

``` bash
php artisan vendor:publish --provider="Spatie\Newsletter\NewsletterServiceProvider"
```

This wil publish a file `laravel-newsletter` in your config directory with the following contents: 
```
<?php

return [

    'mailChimp' => [
        /*
         * The api key of your MailChimp account. You can find yours here:
         * https://us10.admin.mailchimp.com/account/api-key-popup/
         */
        'apiKey' => getenv('MAILCHIMP_APIKEY'),

        /*
         * Here you can define properties of the lists you want to
         * send campaigns.
         */
        'lists' => [
            /*
             * This key is used to identify this list. It can be used
             * in the various methods provided by this package.
             *
             * You can set it to any string you want and you can add
             * as many lists as you want.
             */
            'subscribers' => [
                /*
                 * A mail chimp list id. Check the mailchimp docs if you don't know
                 * how to get this value:
                 * http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id
                 */
                'id' => '',

                /*
                 * These values will be used when creating a new campaign.
                 */
                'fromEmail' => '',
                'fromName' => '',
                'toName' => '',
            ],
        ],
    ],
];

```

## Usage

After you've installed the package and filled in the values in the config-file working with this package will be a breeze.

Subscribing an e-mailadress can be done like this:

```php
Newsletter::subscribe('<EMAIL>');
```

Let's unsubcribe someone:

```php
Newsletter::unsubscribe('<EMAIL>');
```


This is how you create a campaign:

```php
$subject = 'The Truth newsletter';
$contents = '<h1>Big news</h1>The world is carried by four elephants';

Newsletter::createCampaign($subject, $contents);
```

If you have multiple lists defined in the config file you must pass the name of the list an extra parameter:

```php
Newsletter::subscribe('<EMAIL>', 'mySecondList');
Newsletter::unsubscribe('<EMAIL>', 'mySecondList');

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

If you need more functionality you get an instance of the underlying service api with:

```
$api = Newsletter::getApi();
```

As this package currently only supports MailChimp this method will always return an instance of `[MailChimp](https://bitbucket.org/mailchimp/mailchimp-api-php)`.




## Testing

```bash
vendor/bin/phpunit
```

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security

If you discover any security related issues, please email <EMAIL> instead of using the issue tracker.
<commit_msg>edit readme<commit_after>### Work in progress, do not include this package in your project yet...

# Manage newsletters in Laravel 5
[![Latest Version](https://img.shields.io/github/release/freekmurze/laravel-newsletter.svg?style=flat-square)](https://github.com/freekmurze/laravel-newsletter/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/freekmurze/laravel-newsletter/master.svg?style=flat-square)](https://travis-ci.org/freekmurze/laravel-newsletter)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/10993a65-449a-488a-886c-f810b9950070/mini.png)](https://insight.sensiolabs.com/projects/10993a65-449a-488a-886c-f810b9950070)
[![Quality Score](https://img.shields.io/scrutinizer/g/freekmurze/laravel-newsletter.svg?style=flat-square)](https://scrutinizer-ci.com/g/freekmurze/laravel-newsletter)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-newsletter.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-newsletter)

This package provides an easy way to integrate email marketing services with Laravel 5. Currently the package only supports MailChimp. In the future more services may get added.

## Installation

You can install this package via composer using:

```bash
composer require spatie/laravel-newsletter
```

You must also install this service provider.

```php

// config/app.php

'providers' => [
    ...
    'Spatie\Newsletter\NewsletterServiceProvider',
    ...
];
```

If you want to make use of the facade you must install it as well.

```php
// config/app.php
'aliases' => [
    ...
    'Newsletter' => 'Spatie\Newsletter\NewsletterFacade',
];
```

To publish the config file to ``app/config/laravel-newsletter.php`` run:

``` bash
php artisan vendor:publish --provider="Spatie\Newsletter\NewsletterServiceProvider"
```

This wil publish a file `laravel-newsletter` in your config directory with the following contents: 
```
return [

    'mailChimp' => [
        /*
         * The api key of your MailChimp account. You can find yours here:
         * https://us10.admin.mailchimp.com/account/api-key-popup/
         */
        'apiKey' => getenv('MAILCHIMP_APIKEY'),

        /*
         * Here you can define properties of the lists you want to
         * send campaigns.
         */
        'lists' => [
            /*
             * This key is used to identify this list. It can be used
             * in the various methods provided by this package.
             *
             * You can set it to any string you want and you can add
             * as many lists as you want.
             */
            'subscribers' => [
                /*
                 * A mail chimp list id. Check the mailchimp docs if you don't know
                 * how to get this value:
                 * http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id
                 */
                'id' => '',

                /*
                 * These values will be used when creating a new campaign.
                 */
                'fromEmail' => '',
                'fromName' => '',
                'toName' => '',
            ],
        ],
    ],
];

```

## Usage

After you've installed the package and filled in the values in the config-file working with this package will be a breeze.

Subscribing an e-mailadress can be done like this:

```php
Newsletter::subscribe('<EMAIL>');
```

Let's unsubcribe someone:

```php
Newsletter::unsubscribe('<EMAIL>');
```


This is how you create a campaign:

```php
$subject = 'The Truth newsletter';
$contents = '<h1>Big news</h1>The world is carried by four elephants on a turtle!';

Newsletter::createCampaign($subject, $contents);
```

If you have multiple lists defined in the config file you must pass the name of the list an extra parameter:

```php
Newsletter::subscribe('<EMAIL>', 'mySecondList');
Newsletter::unsubscribe('<EMAIL>', 'mySecondList');

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

If you need more functionality you get an instance of the underlying service api with:

```
$api = Newsletter::getApi();
```

As this package currently only supports MailChimp this method will always return an instance of [the MailChimp API](https://bitbucket.org/mailchimp/mailchimp-api-php)`.


## Testing

Run the tests with:
```bash
vendor/bin/phpunit
```

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security

If you discover any security related issues, please email [<EMAIL>](mailto:<EMAIL>) instead of using the issue tracker.

{'fraction_non_alphanumeric': 0.1282578133448686, 'fraction_numerical': 0.012544609062398616, 'mean_word_length': 3.0472647702407003, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 40, 'https://': 26, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3031381', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2731, 'n_words': 771}