Package Data | |
---|---|
Maintainer Username: | techinasia |
Maintainer Contact: | melvin@techinasia.com (Melvin Lee) |
Package Create Date: | 2016-12-07 |
Package Last Update: | 2020-03-16 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:12:56 |
Package Statistics | |
---|---|
Total Downloads: | 24,700 |
Monthly Downloads: | 27 |
Daily Downloads: | 1 |
Total Stars: | 4 |
Total Watchers: | 15 |
Total Forks: | 10 |
Total Open Issues: | 3 |
Use Laravel 5.3 notifications to send mail via Mandrill.
Install this package with Composer:
composer require techinasia/laravel-mandrill-notification-channel
Register the service provider in your config/app.php
:
NotificationChannels\Mandrill\MandrillServiceProvider::class
Add your API key to your configuration at config/services.php
:
'mandrill' => [
'secret' => env('MANDRILL_SECRET', ''),
],
Send mails via Mandrill in your notification:
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:
/**
* Route notifications for the Mandrill channel.
*
* @return array
*/
public function routeNotificationForMandrill()
{
return [
'email' => $this->email,
'name' => $this->name
];
}
You can also specify multiple recipients by supplying an list similar to the to[]
struct of Mandrill API:
/**
* 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',
]
];
}
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.
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:
return (new MandrillMessage())
->subject('Test Subject')
->mergeLanguage('handlebars');
Please see CHANGELOG for more information for what has changed recently.
composer test
If you discover any security related issues, please email dev@techinasia.com instead of using the issues tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.