uttamrabadiya / 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-05-26 04:15:19 UTC
README
先决条件
SendGrid
支持使用其预定义模板发送电子邮件,以格式化邮件消息。在您可以使用 SendGrid 邮件通知之前,您需要通过 Composer 安装通知通道
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');
}