2017 © Pedro Peláez
 

library laravel-mandrill-notification-channel

Mandrill Notifications Channel for Laravel 5.3

image

lonesta/laravel-mandrill-notification-channel

Mandrill Notifications Channel for Laravel 5.3

  • Sunday, February 4, 2018
  • by lonesta
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 4 Versions
  • 10 % Grown

The README.md

Mandrill Notification Channel for Laravel

Dependency Status Build Status Coverage Status StyleCI Status, (*1)

Use Laravel 5.3 notifications to send mail via Mandrill., (*2)

Contents

Installation

Install this package with Composer: ``` bash composer require techinasia/laravel-mandrill-notification-channel, (*3)


Register the service provider in your `config/app.php`: ``` php NotificationChannels\Mandrill\MandrillServiceProvider::class

Setting up Mandrill

Add your API key to your configuration at config/services.php: ``` php 'mandrill' => [ 'secret' => env('MANDRILL_SECRET', ''), ],, (*4)


## Usage Send mails via Mandrill in your notification: ``` php use NotificationChannels\Mandrill\MandrillChannel; use NotificationChannels\Mandrill\MandrillMessage; use Illuminate\Notifications\Notification; class TestNotification extends Notification { public function via($notifiable) { return [MandrillChannel::class]; } public function toMandrill($notifiable) { return (new MandrillMessage()) ->template('foo-bar', ['foo' => 'bar']); } }

You need to specify the email address and name of the notifiable by defining a routeNotificationForMandrill method on the entity:, (*5)

``` php /** * Route notifications for the Mandrill channel. * * @return array */ public function routeNotificationForMandrill() { return [ 'email' => $this->email, 'name' => $this->name ]; }, (*6)


You can also specify multiple recipients by supplying an list similar to the `to[]` struct of [Mandrill API](https://mandrillapp.com/api/docs/messages.php.html): ``` php /** * Route notifications for the Mandrill channel. * * @return array */ public function routeNotificationForMandrill() { return [ [ 'email' => 'a@bar.com', 'name' => 'User A', 'type' => 'to', ], [ 'email' => 'b@bar.com', 'name' => 'User B', 'type' => 'cc', ] ]; }

Available Message methods

  • template(string $name, array $content): Sets the template name and content of the message. If this is set, send-template will be used instead of send.

The following methods work the same as the parameters in send and send-template calls from the Mandrill API., (*7)

  • async(bool $value = true): Enable a background sending mode that is optimized for bulk sending.
  • ip_pool(string $name): Name of the dedicated ip pool that should be used to send the message.
  • send_at(DateTime $datetime): Date / time of when to send the message. Object will be converted to UTC.

You can set any attributes of the message struct by calling the name of attribute in camel case with the value as the parameter:, (*8)

``` php return (new MandrillMessage()) ->subject('Test Subject') ->mergeLanguage('handlebars');, (*9)


## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information for what has changed recently. ## Testing ``` bash composer test

Security

If you discover any security related issues, please email dev@techinasia.com instead of using the issues tracker., (*10)

Contributing

Please see CONTRIBUTING for details., (*11)

Credits

License

The MIT License (MIT). Please see License File for more information., (*12)

The Versions