Laravel 5.1 的 SendCloud 驱动 Laravel-SendCloud

码农软件 · 软件分类 · 网站API · 2019-03-09 06:12:34

软件介绍

Laravel 5.1 的 SendCloud 驱动

普通发送方式完全兼容官方用法,可随时修改配置文件改为其他驱动,而不需要改动业务代码

安装

在项目目录下执行

composer require naux/sendcloud

配置

修改 config/app.php,添加服务提供者

'providers' => [   // 添加这行    Naux\Mail\SendCloudServiceProvider::class,];

.env 中配置你的密钥, 并修改邮件驱动为 sendcloud

MAIL_DRIVER=sendcloud
SEND_CLOUD_USER=   # 创建的 api_user
SEND_CLOUD_KEY=    # 分配的 api_key

使用

普通发送:

用法完全和系统自带的一样, 具体请参照官方文档: http://laravel.com/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 对象,达到目的有几种方法

Mail::send('随便传个空view', [], function ($message) {
    $message->from('us@example.com', 'Laravel');

    $message->to('foo@example.com')->cc('bar@example.com');

    // 模板变量
    $bind_data = ['url' => 'http://naux.me'];
    $template = new SendCloudTemplate('模板名', $bind_data);

    $message->getSwiftMessage()->setBody($template);
});
// 模板变量
$bind_data = ['url' => 'http://naux.me'];
$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');
});

看了上面两种用法,其他用法对照官方文档也能猜出来了吧,如使用 queue 发送等 ~

本文地址:https://codercto.com/soft/d/938.html

服务设计与创新实践

服务设计与创新实践

宝莱恩 (Andy Polaine)、乐维亚 (Lavrans Lovlie)、里森 (Ben Reason) / 王国胜、张盈盈、付美平、赵芳 / 清华大学出版社 / 2015-6-1 / CNY 69.00

产品经济的时代渐行渐远,在以服务为主导的新经济时代,在强调体验和价值的互联网时代,如何才能做到提前想用户之所想?如何比用户想得更周到?如何设计可用、好用和体贴的服务?这些都可以从本书中找到答案。本书撷取以保险业为代表的金融服务、医疗服务、租车及其他种种服务案例,从概念到实践,有理有据地阐述了如何对服务进行重新设计?如何将用户体验和价值提前与产品设计融合在一起? 《服务设计与创新实践》适合产品......一起来看看 《服务设计与创新实践》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具