1

In Laravel Framework 5.4.18 I just ran php artisan make:auth

When I request to reset my password, I get an email that says

(...)

You are receiving this email because we received a password reset request for your account

(...)

Where is the file where it is specified to say that? I want to change it completely.

Notice that here is how to change (only) the general appearance of any notification, and that here is how to change (in addition) the body of the notification.

Thank you very much.

1

2 Answers 2

6

Your User model uses the Illuminate\Auth\Passwords\CanResetPassword trait. This trait has the following function:

public function sendPasswordResetNotification($token)
{
    // use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification
    $this->notify(new ResetPasswordNotification($token));
}

When a password reset is requested, this method is called and uses the ResetPassword notification to send out the email.

If you would like to modify your reset password email, you can create a new custom Notification and define the sendPasswordResetNotification method on your User model to send your custom Notification. Defining the method directly on the User will take precedence over the method included by the trait.

Create a notification that extends the built in one:

use Illuminate\Auth\Notifications\ResetPassword;

class YourCustomResetPasswordNotification extends ResetPassword
{
    /**
     * Build the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('This is your custom text above the action button.')
            ->action('Reset Password', route('password.reset', $this->token))
            ->line('This is your custom text below the action button.');
    }
}

Define the method on your User to use your custom notification:

class User extends Authenticatable
{
    public function sendPasswordResetNotification($token)
    {
        $this->notify(new YourCustomResetPasswordNotification($token));
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

First open a terminal and go to the root of the application and run the following command:

php artisan vendor:publish

You will see some files copied, you can find the email template files in

Root_Of_App/resources/views/vendor

You can edit the Email templates for notifications there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.