如何在控制器Laravel邮件上添加更多参数

我想使用Laravel发送电子邮件,并成功使用此代码

Mail::to($email)->send(new SendMail($name))

现在,我想使用此代码发送更多参数,例如主题,但没有用。 没有错误消息,但电子邮件未发送。

Mail::send(new SendMail($name function($message) use ($email){
    $message->to($email)->subject('Verify your account');
}));

有什么建议吗?预先感谢!

ip0017 回答:如何在控制器Laravel邮件上添加更多参数

您可以在Mailable的build()方法中指定主题

  public function build()
    {
        return $this->subject('Hello there!')->view('view.name');
    }

Mail::send(new SendMail($name function($message) use ($email){
    $message->to($email);
    $message->subject('Verify your Account');
});
,

您可以使用类似的东西

defineProperty

我正在使用通用方法。因此,我可以对需要发送的所有电子邮件使用此方法

本文链接:https://www.f2er.com/2919772.html

大家都在问