cuonggt / laravel-sendgrid-notification-channel
SendGrid Notification Channel for Laravel.
Installs: 2 643
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 6
Open Issues: 0
Requires
- php: ^7.1.3
- guzzlehttp/guzzle: ^6.0
- sendgrid/sendgrid: ^7.2
Requires (Dev)
- illuminate/notifications: ~5.7
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-10-17 23:47:53 UTC
README
Prerequisites
SendGrid
supports sending emails using it's pre-defined templates to format mail messsages. Before you can send SendGrid Mail notifications, you need to install the notification channel via Composer:
cuonggt/laravel-sendgrid-notification-channel
Next, you will need to add a few configuration options to your config/services.php
configuration file. You may copy the example configuration below to get started:
'sendgrid' => [
'api_key' => env('SENDGRID_API_KEY'),
],
Formatting SendGrid Mail Notifications
You should define a toSendGrid
method on the notification class. This method will receive a $notifiable
entity and should return a Illuminate\Notifications\Messages\SendGridMessage
instance:
/**
* Get the SendGrid representation of the notification.
*
* @param mixed $notifiable
* @return SendGridMessage
*/
public function toSendGrid($notifiable)
{
return (new SendGridMessage('Your SendGrid template ID'))
->from('test@example.com', 'Example User')
->to('test+test1@example.com', 'Example User1');
}