dousu1900 2018-10-26 02:40
浏览 35

在laravel中发送电子邮件时调用客户端电子邮件地址

i am sending email my code is like this

public function postApprovedDemand( Demandrequest $demand){
$reuestemail = $demand->email;
$gettoken = $demand->token;
$get_id = $demand->id;
$approvedlink = 'example.com/'.$gettoken.'/'.$get_id;
$data = array(
    'name' => $demand->name,
     'demail'=>$demand->email,
      'token'=>$demand->token,
     'link'=>$approvedlink
);
 Mail::send('mail.projectrequest', $data, function ($message) {
    $message->from('info@example.com');
    $message->to($requestemail);
    $message->subject('Demand Request link');
});
return redirect()->back()->with('message', 'Demark form link has been send successfully.');}

while i am sending the email its say $requestemail not found. if i direct type email its working. My question is how i pass the $requestemail = $demand->email in $message->to(???????). i am using laravel 6.5.

  • 写回答

1条回答 默认 最新

  • douxi3233 2018-10-26 02:47
    关注

    To pass a variable in an anonymous function you can use

    functions.anonymous

    Mail::send('mail.projectrequest', $data, function ($message) use ($requestemail) {
        $message->from('info@example.com');
        $message->to($requestemail);
        $message->subject('Demand Request link');
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答