cuonggt / laravel-sendgrid-notification-channel
Laravel 的 SendGrid 通知通道。
v1.0.0
2019-03-19 15:21 UTC
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-09-17 23:37:09 UTC
README
先决条件
SendGrid
支持使用预定义模板发送电子邮件。在您可以通过 Composer 安装通知通道并发送 SendGrid 邮件通知之前,您需要这样做。
cuonggt/laravel-sendgrid-notification-channel
接下来,您需要在您的 config/services.php
配置文件中添加一些配置选项。您可以复制下面的示例配置以开始
'sendgrid' => [
'api_key' => env('SENDGRID_API_KEY'),
],
格式化 SendGrid 邮件通知
您应该在通知类上定义一个 toSendGrid
方法。此方法将接收一个 $notifiable
实体,并应返回一个 Illuminate\Notifications\Messages\SendGridMessage
实例。
/**
* 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');
}