Laravel技巧集锦(22):使用sendcloud发送邮件

版权声明:http://www.itchuan.net https://blog.csdn.net/sinat_37390744/article/details/88738359

SendCloud官网https://www.sendcloud.net/

准备:SendCloud官网注册账号,每天有免费发送条数,获取APP_USER、APP_KEY、模板

1、安装naux/sendcloud拓展

composer require naux/sendcloud

2、注册

\Naux\Mail\SendCloudServiceProvider::class,

3、env配置

MAIL_DRIVER=sendcloud
SEND_CLOUD_USER= ***
SEND_CLOUD_KEY=  ***

4、控制器使用

private function sendEmail($email){

        $data = ['name'=>'jack'];
        $template =new SendCloudTemplate('***',$data);//yourTemplateName
        Mail::raw($template,function ($message) use ($email){
            $message->from('**@***','***');
            $message->to($email);
        });

  }

猜你喜欢

转载自blog.csdn.net/sinat_37390744/article/details/88738359