You can change your password reset email subject, but it will need some extra work. First, you need to create your own implementation of ResetPassword
notification.
Create a new notification class insideappNotifications
directory, let's named it ResetPassword.php
:
<?php
namespace AppNotifications;
use IlluminateNotificationsNotification;
use IlluminateNotificationsMessagesMailMessage;
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 are receiving this email because we received a password reset request for your account.')
->action('Reset Password', url('password/reset', $this->token))
->line('If you did not request a password reset, no further action is required.');
}
}
You can also generate the notification template using artisan command:
php artisan make:notification ResetPassword
Or you can simply copy-paste the above code. As you may notice this notification class is pretty similar with the default IlluminateAuthNotificationsResetPassword
. You can actually just extend it from the default ResetPassword
class.
The only difference is here, you add a new method call to define the email's subject:
return (new MailMessage)
->subject('Your Reset Password Subject Here')
You may read more about Mail Notifications here.
Secondly, on your appUser.php
file, you need to override the default sendPasswordResetNotification()
method defined by IlluminateAuthPasswordsCanResetPassword
trait. Now you should use your own ResetPassword
implementation:
<?php
namespace App;
use IlluminateNotificationsNotifiable;
use IlluminateFoundationAuthUser as Authenticatable;
use AppNotificationsResetPassword as ResetPasswordNotification;
class User extends Authenticatable
{
use Notifiable;
...
public function sendPasswordResetNotification($token)
{
// Your your own implementation.
$this->notify(new ResetPasswordNotification($token));
}
}
And now your reset password email subject should be updated!
Hope this help!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…