Framework: Can not customize the mail components in HTML blade template (not Markdown template)

Created on 23 Mar 2017  路  3Comments  路  Source: laravel/framework

  • Laravel Version: 5.4.15
  • PHP Version: 5.6
  • Database Driver & Version: mysql

Description:

I want to customize the mail template components by following the guide of Laravel 5.4, but I get an Error after that:

ErrorException in FileViewFinder.php line 112:
No hint path defined for [mail]. (View: /resources/views/emails/html/order/confirmed.blade.php)

Reason for using HTML template instead of Markdown :

For markdown template, I was unable to embed image in the mail because of this bug:
https://github.com/laravel/framework/issues/17629

Steps To Reproduce:

  1. php artisan make:mail OrderConfirmed
  2. php artisan vendor:publish --tag=laravel-mail
  3. create a html blade template in /resources/views/emails/html/order/confirmed.blade.php
  4. use the blade template in App\Mail\OrderConfirmed.php

resources/views/emails/html/order/confirmed.blade.php:

@component('mail::message')
<h1>Order Confirmed</h1>
<p>Your order is confirmed!</p>

@component('mail::button', ['url' => $url])
View Order
@endcomponent

<p>
Thanks,<br>
{{ config('app.name') }}
</p>
@endcomponent

App\Mail\OrderConfirmed.php:

<?php
namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\URL;

use App\Order;

class OrderConfirmed extends Mailable
{
    use Queueable, SerializesModels; 

    /**
     * The order instance.
     *
     * @var Order
     */
    public $order;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct(Order $order)
    {
        $this->order = $order;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->view('emails.html.order.confirmed')->with(['url' => URL::to('order/show/'.$this->order->id)]);
    }
}

Most helpful comment

These views are used to render the HTML version of the markdown email, I know it may be confusing a bit but these views are only available when you're sending a markdown email.

When you send a markdown email laravel creates an HTML version as well as a markdown version of your email, the html views you are referring are not publicly available as a blade template, they're only accessible from within the markdown email.

All 3 comments

These views are used to render the HTML version of the markdown email, I know it may be confusing a bit but these views are only available when you're sending a markdown email.

When you send a markdown email laravel creates an HTML version as well as a markdown version of your email, the html views you are referring are not publicly available as a blade template, they're only accessible from within the markdown email.

@themsaid sorry it's my misunderstanding, I will give markdown mail another try, thanks.

Are you 'themsaid' saying blade rendering is only for markdown?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

progmars picture progmars  路  3Comments

felixsanz picture felixsanz  路  3Comments

klimentLambevski picture klimentLambevski  路  3Comments

PhiloNL picture PhiloNL  路  3Comments