I write a mailable
to send email when user registers,I do it following the document(https://laravel.com/docs/5.5/mail):
first,generating a mailable:
php artisan make:mail UserRegistered
Ok,thus there is a UserRegistered.php
file in the app/Mail
directory,and I write the build()
method like this:
public function build()
{
return $this->view('emails.activate-user')
->with([
'name' => $this->user->name,
'url' => route('activateUser',['token'=>$this->user->confirmation_token])
]);
}
The email can be sent successfully,the title of the email is User Registered
,I want to customize the title ,how to do it?
You have to use subject
method
public function build()
{
return $this->view('emails.activate-user')
->subject("My mail title")
->with([
'name' => $this->user->name,
'url' => route('activateUser',['token'=>$this->user->confirmation_token])
]);
}
Or update your mails class's constructor
public function __construct()
{
$this->subject('Sample title');
}
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