php - How to change reset password email subject in laravel? -


i beginner in laravel. learning framework. curent laravel version 5.3.

i scaffolding auth using php artisan make:auth working fine. configured gmail smtp in .env file , mail.php in config directgory. working. saw by-default forgot password email subject going reset password. want change that.

i saw blog. found blog. have implement in site. same output coming.

i followed these links -

https://laracasts.com/discuss/channels/general-discussion/laravel-5-password-reset-link-subject

https://laracasts.com/discuss/channels/general-discussion/reset-password-email-subject

https://laracasts.com/discuss/channels/laravel/how-to-override-message-in-sendresetlinkemail-in-forgotpasswordcontroller

you can change password reset email subject, need work. first, need create own implementation of resetpassword notification.

create new notification class insideapp\notifications directory, let's named resetpassword.php:

<?php  namespace app\notifications;  use illuminate\notifications\notification; use illuminate\notifications\messages\mailmessage;  class resetpassword extends notification {     public $token;      public function __construct($token)     {         $this->token = $token;     }      public function via($notifiable)     {         return ['mail'];     }      public function tomail($notifiable)     {         return (new mailmessage)             ->subject('your reset password subject here')             ->line('you receiving email because received password reset request account.')             ->action('reset password', url('password/reset', $this->token))             ->line('if did not request password reset, no further action required.');     } } 

you can generate notification template using artisan command:

php artisan make:notification resetpassword 

or can copy-paste above code. may notice notification class pretty similar default illuminate\auth\notifications\resetpassword. can extend default resetpassword class.

the difference here, add new method call define email's subject:

return (new mailmessage)         ->subject('your reset password subject here') 

you may read more mail notifications here.

secondly, on app\user.php file, need override default sendpasswordresetnotification() method defined illuminate\auth\passwords\canresetpassword trait. should use own resetpassword implementation:

<?php  namespace app;  use illuminate\notifications\notifiable; use illuminate\foundation\auth\user authenticatable; use app\notifications\resetpassword resetpasswordnotification;  class user extends authenticatable {     use notifiable;      ...      public function sendpasswordresetnotification($token)     {         // your own implementation.         $this->notify(new resetpasswordnotification($token));     } } 

and reset password email subject should updated!

reset password email subject updated

hope help!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -