How to customize password recovery email (Laravel 5.4)

6

How can I customize the password recovery email for Laravel 5.4, I need to change the language but can not find the place to edit.

    
asked by anonymous 02.03.2017 / 12:10

3 answers

7

Step-by-step instruction:

You must create a new notification class to override the default message text.

  • To create a new notification class you must use this command line:

    php artisan make:notification meuResetDeSenha
    
  • This will create the new class 'myResetDeSenha' in the app / Notifications directory.

  • Change the constructor of the generated file to:

    public function __construct($token)
    {
        $this->token = $token;
    }
    
  • Add the following import to the user's template (probably in app / User.php):

    use App\Notifications\meuResetDeSenha;
    
  • Add this new method to the user template:

    public function sendPasswordResetNotification($token)
    {
        $this->notify(new meuResetDeSenha($token));
    }
    
  • Turn the following artisan command to publish the changes.

    php artisan vendor:publish --tag=laravel-notifications 
    
  • After running this command, the notification mail template will be located in the resources / views / vendor / notifications

  • Edit the inline and action text of the toMail () method in your myResetDeSenha class

    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('Assunto do email')
            ->greeting('Olá!')
            ->line('Você está recebendo este e-mail porque nós recebemos uma requisição para sua conta.')
            ->action('REDEFINIR SENHA', route('password.reset', $this->token))
            ->line('Se você não requisitou uma redefiniçã de senha, nenhuma ação é necessária.')
            ->markdown('vendor.notifications.email');
    }
    
  • This is described in link

  • Edit the email text in resources / views / vendor / notifications / email.blade.php if you want.
  • Although most will be translated from link , I added step 2 in my answer because I needed to implement it to work here and I added the markdown in step 6.

        
    10.04.2017 / 21:25
    1

    the translation files are in the resource / lang / the file referring to the login areas is auth.php you can edit it as you want.

        
    02.03.2017 / 20:25
    0

    I think the file is this:

    resources / views / vendor / notifications / email.blade.php

        
    03.04.2017 / 20:29