我正在尝试自定义通过电子邮件发送通知时使用的HTML电子邮件布局。
我已经发布了邮件和通知视图。
php artisan vendor:publish --tag=laravel-mail
php artisan vendor:publish --tag=laravel-notifications
如果我修改/resources/views/vendor/notifications/email.blade.php
文件,我只能更改发送的电子邮件的BODY内容。我想修改页眉、页脚和电子邮件布局的每个其他部分。
我还尝试修改/resources/vendor/mail/html/
中的视图,但是无论何时发送通知,它都不会使用这些视图,而是使用默认的laravel框架视图。
我知道可以在我的通知类返回的MailMessage
上设置视图,但我希望保留标准的line()
、greeting()
等函数。
有人知道如何让我的通知使用/resources/vendor/mail/html
中的视图发送电子邮件吗?
以下是我的/resources/views/vendor/notifications/email.blade.php
文件,但它没有任何地方可以自定义页眉/页脚/整体布局。
@component('mail::message')
{{-- Greeting --}}
@if (! empty($greeting))
# {{ $greeting }}
@else
@if ($level == 'error')
# Whoops!
@else
# Hello!
@endif
@endif
{{-- Intro Lines --}}
@foreach ($introLines as $line)
{{ $line }}
@endforeach
{{-- Action Button --}}
@if (isset($actionText))
<?php
switch ($level) {
case 'success':
$color = 'green';
break;
case 'error':
$color = 'red';
break;
default:
$color = 'blue';
}
?>
@component('mail::button', ['url' => $actionUrl, 'color' => $color])
{{ $actionText }}
@endcomponent
@endif
{{-- Outro Lines --}}
@foreach ($outroLines as $line)
{{ $line }}
@endforeach
<!-- Salutation -->
@if (! empty($salutation))
{{ $salutation }}
@else
Regards,<br>{{ config('app.name') }}
@endif
<!-- Subcopy -->
@if (isset($actionText))
@component('mail::subcopy')
If you’re having trouble clicking the "{{ $actionText }}" button, copy and paste the URL below
into your web browser: [{{ $actionUrl }}]({{ $actionUrl }})
@endcomponent
@endif
@endcomponent
return (new MailMessage)
等等。我正在尝试找出如何自定义new MailMessage
的布局。 - Brian Glaz$user->notify(new TeamInvitation())
- Brian Glazthemes/default.css
以及发布的themes/default.css
,但电子邮件通知看起来仍然完全相同。 - Brian Glaz