2017-09-04 35 views
1

從這裏:Laravel 5.4 - How to customize notification email layout?如何解決「沒有爲[郵件]定義提示路徑」。 (自定義電子郵件佈局)laravel?

我嘗試定製電子郵件通知佈局

我的代碼發送電子郵件這樣的:

public function toMail($notifiable) 
{ 
    return (new MailMessage) 
       ->subject('Test') 
       ->view('vendor.mail.markdown.message',['data'=>$this->data]); 
} 

這樣的觀點:

@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 

如果代碼執行,存在這樣的錯誤:

(2/2)ErrorException不爲[郵件]定義提示路徑。 (查看: C:\ XAMPP \ htdocs中\ myshop \資源\意見\供應商\郵件\降價\ message.blade.php)

我怎樣才能解決這個錯誤嗎?

+0

嘗試此命令從包發佈郵件目錄的意見PHP工匠廠商:發佈--tag = laravel-mail – umefarooq

+0

@umefarooq,我已經做到了。但它是一樣的 –

回答

2

如果你在你的模板使用降價,你需要使用->markdown()方法,而不是->view()方法對你MailMessage

public function toMail($notifiable) 
{ 
    return (new MailMessage) 
      ->subject('Test') 
      ->markdown('vendor.mail.markdown.message',['data'=>$this->data]); 
} 
+0

與OP相同的問題,我沒有使用降價,但這解決了問題。 –

相關問題