I'm trying to change the default subject
field in the verification email that comes with Laravel 5.7. How and where do I change it? I have searched all over the place and online. Because it's brand new I can't find an answer.
Laravel provides subject() where we can change the subject of the email. We will change the following code on MyTestMail class as follows and you will see how to change from name and address with output. Read Also: How to Send Email to Multiple Users in Laravel? * Create a new message instance.
You don't need to code anything. The notification has all the strings wrapped in the Lang class so that you can provide translation strings from english to another language, or even english to english if you just want to change the wording.
Look in /vendor/laravel/framework/src/Illuminate/Auth/Notifications/VerifyEmail.php
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
return (new MailMessage)
->subject(Lang::getFromJson('Verify Email Address'))
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
->action(
Lang::getFromJson('Verify Email Address'),
$this->verificationUrl($notifiable)
)
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
}
You can see all the strings there.
Create a file en.json if you don't have one on the resources/lang folder already.
add the original string and the replacement. eg
{
"Verify Email Address": "My preferred subject",
"Please click the button below to verify your email address.":"Another translation"
}
To translate to another language, change the locale in config/app.php and create a translation file with the locale.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With