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
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!
hope help!
Comments
Post a Comment