laravel邮件发送

1.配置邮件参数,根目录.env文件

MAIL_DRIVER=smtp
MAIL_HOST=smtp.qq.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=xxxxxxxxx
MAIL_ENCRYPTION=ssl

2.发送方式1

public function mail(){
        Mail::raw('邮件内容 1',function($message){
            $message->from('[email protected]',"youoer站点");
            $message->subject('邮件主题 2');
            $message->to('[email protected]');
        });
    }

3.发送方式2,发送html文件格式

public function mail2(){
        //参数1:控制器名字
        //参数2:传到视图文件的变量
        Mail::send('index.mail',['name'=>"感谢有你"],function($message){
            $message->to('[email protected]');
        });
    }

猜你喜欢

转载自blog.csdn.net/qq_39940866/article/details/80282154