Laravel5.1的SedCloud驱动
普通发送方式完全兼容官方用法,可随时修改配置文件改为其他驱动,而不需要改动业务代码
安装在项目目录下执行
composer require aux/sedcloud配置修改cofig/app.php,添加服务提供者
'providers' => [ // 添加这行 Naux\Mail\SedCloudServiceProvider::class,];在.ev中配置你的密钥,并修改邮件驱动为sedcloud
MAIL_DRIVER=sedcloudSEND_CLOUD_USER= # 创建的 api_userSEND_CLOUD_KEY= # 分配的 api_key使用普通发送:用法完全和系统自带的一样,具体请参照官方文档:https://laravel.com/docs/5.1/mail
Mail::sed('emails.welcome', $data, fuctio ($message) { $message->from('us@example.com', 'Laravel'); $message->to('foo@example.com')->cc('bar@example.com');});模板发送用法和普通发送类似,不过需要将body设置为SedCloudTemplate对象,达到目的有几种方法
Mail::sed('随便传个空view', [], fuctio ($message) { $message->from('us@example.com', 'Laravel'); $message->to('foo@example.com')->cc('bar@example.com'); // 模板变量 $bid_data = ['url' => 'https://aux.me']; $template = ew SedCloudTemplate('模板名', $bid_data); $message->getSwiftMessage()->setBody($template);});// 模板变量$bid_data = ['url' => 'https://aux.me'];$template = ew SedCloudTemplate('模板名', $bid_data);Mail::raw($template, fuctio ($message) { $message->from('us@example.com', 'Laravel'); $message->to('foo@example.com')->cc('bar@example.com');});看了上面两种用法,其他用法对照官方文档也能猜出来了吧,如使用queue发送等~
评论