Reputation: 1563
I want to make my mail more detailed when the user has sent a forgot password reset link to his/her email. This is the sample of the picture when receiving a reset password link.
I want to add some details here that the Hello should be Hello! (user name here)
Here is the code that I added in my 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);
}
and it should pass the data to app\Notifications\ApplicantResetPasswordNotification.php
public function toMail($notifiable)
{
return (new MailMessage)
->from('[email protected]', '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.');
}
Looking for help on how to pass the data or how to query it. Would appreciate if someone could help me Thanks in advance.
Upvotes: 1
Views: 2879
Reputation: 1671
In your ApplicationResetPasswordNotification.php
you can use the $notifiable
variable as follows:
public function toMail($notifiable)
{
return (new MailMessage)
->from('[email protected]', 'CCV3')
->greeting('Hello!' . $notifiable->name) // Applicant name
...
}
Please mark as answer if that works for you!
Upvotes: 6
Reputation: 403
This is the another way to send the mail in 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('[email protected]');
$message->to( $data['email'] )->subject('Forgot Password Link');
});
Where as 'email/forgotmail
' is in 'resources/views/email/forgotmail.blade.php
' that you have to create. So that here you can put your email template over here and make use of $data in it .
Upvotes: 0