Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fortify - How to customise verification / password reset emails?

I'm in the process of implementing fortify into my app. I'm really confused about customising the default emails that are produced when you hit the password-reset / verifty-email routes?

I could edit them in vendor but that going to cause me an issue every time I update.

There must be a hook to provide an alternative email template.

Unfortnatly I cant find any documentation that explains how its done.

Do I need to add:

public function sendEmailVerificationNotification()
{


}

To my user model? If so how to I generate the return verificaiton URL as its not being held in the database?

Any help would be great.

Thanks!

like image 831
swift--help Avatar asked Aug 31 '25 17:08

swift--help


1 Answers

You can customize the password reset email by adding the following in FortifyServiceProvider

ResetPassword::toMailUsing(function($user, string $token) {
    return (new MailMessage)
        ->subject('Reset Password')
        ->view('emails.password_reset', [
            'user' => $user,
            'url' => sprintf('%s/users/password_reset/%s', config('app.url'), $token)
    ]);
});

Create a file named resources/views/emails/password_reset.blade.php, in this file you can use $user and $url

like image 187
Tycho Avatar answered Sep 04 '25 08:09

Tycho