如何在发送邮件布局 laravel 5.3 上自定义发件人和 header?

How can I custom sender and header on send mail layout laravel 5.3?

我的代码是这样的:

public function toMail($notifiable)
{
    return (new MailMessage)
                ->subject('You have new follower')
                ->greeting('Hello!')
                ->line('Welcome to my application')
                ->line('Thank you');
}

结果是这样的:

看我用蓝色标记了。我想定制那个。

我在 https://laravel.com/docs/5.3/notifications#mail-notifications 上看了,但没找到

如何自定义?

您可能需要更改配置。

config/app.phpname 值更改为您喜欢的值 在 config/mail.php 中,您可以编辑 from 值。

如果您希望 from 与默认 from 不同,您可以在 MailMessage 链中调用 from 方法。

public function toMail($notifiable)
{
    return (new MailMessage)
                ->subject('You have new follower')
                ->from('cthulhu@microsoft.com', 'Moses Toh')
                ->greeting('Hello!')
                ->line('Welcome to my application')
                ->line('Thank you');
}

此外,如果您想实际修改电子邮件的 layout/html/css,请在此处 https://laravel.com/docs/5.3/notifications#mail-notifications

查看 自定义模板 部分

You can modify the HTML and plain-text template used by mail notifications by publishing the notification package's resources. After running this command, the mail notification templates will be located in the resources/views/vendor/notifications directory:

php artisan vendor:publish --tag=laravel-notifications