Laravel 5.4 changes the subject of postage marking

I used markdown mailables, which is a new feature in laravel 5.4. I have successfully implemented a mail sender. It seems the subject of the letter is called the name of the class that you can mailable. I need to change the subject of the letter, and it’s hard to find any resources about this.

+9
source share
2 answers

There is a subject method in laravel email messages.

All configuration of the postal class is done in the build method. Within this method, you can call various methods, for example, a subject , view and attach to configure the presentation and delivery of email .: https://laravel.com/docs/5.4/mail#writing-mailables

You can achieve this as follows:

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->from('example@example.com')
                ->subject('Your Subject')
                ->markdown('emails.orders.shipped');
}

You may need to execute php artisan view:clearafter changing your class.

+27
source

If the subject of the message is the same for all letters, simply overload the $ subject parameter in the extended Mailable class.

/**
 * The subject of the message.
 *
 * @var string
 */
public $subject;
0
source

Source: https://habr.com/ru/post/1674952/


All Articles