当用户向他/她的电子邮件发送忘记密码重置链接时,我想让我的邮件更加详细。这是收到重置密码链接时的图片样本。
我想在这里添加一些Hello应该是Hello的细节! (此处的用户名)
以下是我在 SendsPasswordResetEmails.php
中添加的代码public function sendResetLinkEmail(Request $request)
{
$this->validateEmail($request);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('email')
);
$applicant_name = Applicant::where('email', $request->email)->get()->value('name');
return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($response)
: $this->sendResetLinkFailedResponse($request, $response);
}
它应该将数据传递给 app \ Notifications \ ApplicantResetPasswordNotification.php
public function toMail($notifiable)
{
return (new MailMessage)
->from('vcc3dummy@gmail.com', 'CCV3')
->greeting('Hello! Applicant Name') // Applicant name pass here
->line('You are receiving this email because we received a password request for your account.')
->action('Click here to Reset Password', route('applicant.reset', $this->token))
->line('If you did not reset your password, no further action is required.');
}
寻求有关如何传递数据或如何查询数据的帮助。 如果有人能帮助我,我将不胜感激 提前谢谢。
答案 0 :(得分:2)
在ApplicationResetPasswordNotification.php
中,您可以使用$notifiable
变量,如下所示:
public function toMail($notifiable)
{
return (new MailMessage)
->from('vcc3dummy@gmail.com', 'CCV3')
->greeting('Hello!' . $notifiable->name) // Applicant name
...
}
如果适合你,请标记为答案!
答案 1 :(得分:0)
这是另一种在laravel中发送邮件的方式 -
Put that data you want to use/show in email template
。
$data = [
'email' => $email,
'remember_token' => $remember_token,
'name' => $applicant_name
];
Mail::send('emails/forgotmail', $data, function ($message) use ($data) {
$message->from('youremail@gmail.com');
$message->to( $data['email'] )->subject('Forgot Password Link');
});
' email/forgotmail
'在' resources/views/email/forgotmail.blade.php
'你必须创造。所以在这里你可以把你的电子邮件模板放在这里,并使用其中的$ data。