composer.json 增加
"illuminate/mail":"5.6"
composer update -vvv
config 目录新建mail.php
<?php return [ 'driver' => env('MAIL_DRIVER', 'smtp'), 'host' => env('MAIL_HOST', 'smtp.qq.com'), 'port' => env('MAIL_PORT', 465), 'from' => [ 'address' => env("MAIL_USERNAME", ""), 'name' => env("MAIL_FROM_NAME") ], 'encryption' => env('MAIL_ENCRYPTION'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => env('MAIL_PRETEND', false), ];
env增加配置
#邮件配置 MAIL_DRIVER=smtp MAIL_HOST=smtp.qq.com MAIL_PORT=465 MAIL_USERNAME=邮箱 MAIL_PASSWORD=密码 MAIL_FROM_NAME=发件人名字 好像没什么卵用,收到的邮件是自动识别发件人昵称 MAIL_ENCRYPTION=ssl
密码是qq邮件 设置 -账户 获得的授权码
bootstrap 下面 app.php里面增加代码
$app->configure('mail'); //加载配置文件
控制器测试
Mail::raw($content, function ($message) use($to,$subject,$content) { $message ->to($to)->subject($subject); });