digitspark / sendcloud
0.03
2022-09-05 09:51 UTC
Requires
- php: >=5.6
- guzzlehttp/guzzle: 5.5|^6.0|^7.0|^8.0
- illuminate/mail: 5.5|^6.0|^7.0|^8.0
- illuminate/support: ^5.5|^6.0|^8.0
Requires (Dev)
- phpstan/phpstan: ^0.11.15
This package is auto-updated.
Last update: 2024-09-05 14:40:39 UTC
README
为 Laravel 提供的 SendCloud 驱动,发送方式完全兼容官方用法,可随时修改配置文件改为其他驱动,而无需修改业务代码
Laravel 5.5
及以下版本请使用1.1.3
版本,并手动将 ServiceProvier 添加到config/app.php
安装
composer require digitspark/sendcloud
配置
在 .env
中配置您的密钥,并将邮件驱动修改为 sendcloud
MAIL_DRIVER=sendcloud SEND_CLOUD_USER= # 创建的 api_user SEND_CLOUD_KEY= # 分配的 api_key
使用
普通发送方式:
用法与系统自带完全一样,具体请参考官方文档: https://laravel.net.cn/docs/5.1/mail
Mail::send('emails.welcome', $data, function ($message) { $message->from('us@example.com', 'Laravel'); $message->to('foo@example.com')->cc('bar@example.com'); });
模板发送方式
用法与普通发送类似,但需要将 body
设置为 SendCloudTemplate
对象
注意:使用模板发送不与其他邮件驱动兼容
// 模板变量 $bind_data = ['url' => 'http://digitspark.com']; $template = new SendCloudTemplate('模板名', $bind_data); Mail::raw($template, function ($message) { $message->from('us@example.com', 'Laravel'); $message->to('foo@example.com')->cc('bar@example.com'); });