how can I edit the email template that is being sent when resetting passwords or verifying the email addresses. Image of the sample email
CodePudding user response:
You should change the default Laravel sendPasswordResetNotification method on your User model.
Because the lines are come from Illuminate\Auth\Notifications\ResetPassword.php. Never you must change this facade. If you do it you can lost changes during an update of Laravel.
Instead of it do this, add the following to your your User model.
use App\Notifications\PasswordReset; // Or the location that you store your notifications (this is default).
/**
* Send the password reset notification.
*
* @param string $token
* @return void
*/
public function sendPasswordResetNotification($token)
{
$this->notify(new PasswordReset($token));
}
Create create that notification:
php artisan make:notification PasswordReset
And example of this notification's content:
/**
* The password reset token.
*
* @var string
*/
public $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Build the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('You are receiving this email because we received a password reset request for your account.') // Here are the lines you can safely override
->action('Reset Password', url('password/reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
}
CodePudding user response:
Import email template using the following command
php artisan vendor:publish --tag=laravel-mail
Then you can edit your html/text template in this folder
resources/views/vendor/mail
https://laravel.com/docs/8.x/mail#customizing-the-components