Laravel发送邮件
.env文件配置
MAIL_MAILER=smtp
MAIL_HOST=smtp.163.com
MAIL_PORT=465
MAIL_USERNAME=ayiui4566@163.com
MAIL_PASSWORD=邮箱密码
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=ayiui4566@163.com
MAIL_FROM_NAME="${APP_NAME}"
代码部分
public function mail(){ $m3_email = new \stdClass(); $m3_email->to = "254646295@qq.com"; $m3_email->cc = 'magina@speakez.cn'; $m3_email->subject = '凯恩书店验证'; $m3_email->content = '请于24小时点击该链接完成验证. http://book.magina.com/service/validate_email' . '?member_id=' . 10001 . '&code=' . Str::uuid(); $flag = Mail::send('email_register', ['m3_email' => $m3_email], function ($m) use ($m3_email) { // $m->from('hello@app.com', 'Your Application'); $m->to($m3_email->to, '尊敬的用户') ->cc($m3_email->cc) ->subject($m3_email->subject); }); return $flag ?'发送成功':'发送失败'; }