n Changing the Laravel password reset email text | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Changing the Laravel password reset email text

 

Create a custom notification

php artisan make:notification MailResetPasswordToken


edit this file which you find in a new folder App\Notifications


<?php
 
namespace App\Notifications;
 
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
 
class MailResetPasswordToken extends Notification
{
    use Queueable;
 
    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'];
    }
 
    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
                    ->subject("Reset your password")
                    ->line("Hey, did you forget your password? Click the button to reset it.")
                    ->action('Reset Password', url('password/reset', $this->token))
                    ->line('Thankyou for being a friend');
    }
 
}

 

Override the send password reset trait with your local implementation in your User.php user model

/**
 * Send a password reset email to the user
 */
public function sendPasswordResetNotification($token)
{
    $this->notify(new MailResetPasswordToken($token));
}

 

 

Alter the layout of the message

If you need to alter the layout of the message, including the text “If you’re having trouble clicking the “Reset Password” button,” then you need to run

php artisan vendor:publish

and then edit the files in

/resources/views/vendor/notifications

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook