Laravel实现发送邮箱(126)
程序员文章站
2022-03-14 17:52:13
...
.env 加配置
MAIL_DRIVER=smtp
MAIL_HOST=smtp.126.com
MAIL_PORT=465
MAIL_USERNAME=邮箱账号
MAIL_PASSWORD=授权密码
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=邮箱
MAIL_FROM_NAME=要显示的名字
126邮箱配置
/**
* 发送邮箱
*/
use Illuminate\Support\Facades\Mail;
public function sendEmail(){
$message = '我是测试哦';
$to = 'aaa@qq.com';
$subject = '你好啊 ';
Mail::send(
'TestPay.emails.test', //视图地址
['content' => $message],
function ($message) use($to, $subject) {
$message->to($to)->subject($subject);
}
);
return response()->json(['status' => '0', 'message' => '测试','result'=>""]);
}
试图: