numesia / mailjet
Mailjet Notifications driver
1.4
2024-07-29 14:42 UTC
Requires
- php: >=7.2.5
- guzzlehttp/guzzle: ~7.0
- illuminate/notifications: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0
- mailjet/laravel-mailjet: ^3.0
Requires (Dev)
- mockery/mockery: 0.9.*|^1.0
- phpunit/phpunit: ~7.0|^8.0|^9|^10.0
README
This package makes it easy to send notifications using Mailjet with Laravel 5.5+, 6.x and 7.x.
Contents
Prerequisite
Configure https://github.com/mailjet/laravel-mailjet
Installation
You can install the package via composer:
composer require numesia/mailjet
Add the Mailjet Provider :
'providers' => [
...
Numesia\Mailjet\MailjetServiceProvider::class,
...
]
Usage
Now you can use the channel in your via()
method inside the notification:
use Numesia\Mailjet\MailjetChannel; use Numesia\Mailjet\MailjetMessage; use Illuminate\Notifications\Notification; class ProjectCreated extends Notification { public function via($notifiable) { return [MailjetChannel::class]; // or 'mailjet' } public function toMailjet($notifiable) { return (new MailjetMessage) ->sender("sender@email.com") ->name("Sender Name") ->subject("My Subject") ->content("My Html Content"); // or ->view("view:location", []) } }
In order to let your Notification know which email to use, add the routeNotificationForMailjet
method to your Notifiable model.
This method needs to return an email.
public function routeNotificationForMailjet(Notification $notification) { return $this->email; }
Testing
$ composer test