如何解决“没有为 [mail] 定义提示路径”。(自定义电子邮件布局)在 Laravel 上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46032388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I solve "No hint path defined for [mail]." (customize email layout) on laravel?
提问by Success Man
From here : Laravel 5.4 - How to customize notification email layout?
从这里:Laravel 5.4 - 如何自定义通知电子邮件布局?
I try customize notification email layout
我尝试自定义通知电子邮件布局
My code to send email like this :
我发送电子邮件的代码如下:
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Test')
->view('vendor.mail.markdown.message',['data'=>$this->data]);
}
The view like this :
像这样的视图:
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
@endcomponent
@endslot
{{-- Body --}}
{{ $slot }} test
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
? {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@endcomponent
@endslot
@endcomponent
If the code executed, there exist error like this :
如果代码执行,存在这样的错误:
(2/2) ErrorException No hint path defined for [mail]. (View: C:\xampp\htdocs\myshop\resources\views\vendor\mail\markdown\message.blade.php)
(2/2) ErrorException 没有为 [mail] 定义提示路径。(查看:C:\xampp\htdocs\myshop\resources\views\vendor\mail\markdown\message.blade.php)
How can I solve the error?
我该如何解决错误?
回答by Joe
If you are using markdown in your template, you need to use the ->markdown()
method rather than the ->view()
method on your MailMessage
如果您在模板中使用 markdown,则需要使用该->markdown()
方法而不是您的模板中的->view()
方法MailMessage
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Test')
->markdown('vendor.mail.markdown.message',['data'=>$this->data]);
}
回答by madbob
In an application migrated through different Laravel versions (and now at 5.6) I had to modify the file config/mail.php
, changing the parameter markdown/paths
from resource_path('views/vendor/mail')
to resource_path('views/vendor/mail/markdown')
, so it found the base templates for my Markdown mails.
在通过不同 Laravel 版本(现在是 5.6)迁移的应用程序中,我必须修改文件config/mail.php
,将参数markdown/paths
从更改resource_path('views/vendor/mail')
为resource_path('views/vendor/mail/markdown')
,因此它找到了我的 Markdown 邮件的基本模板。