No hint path defined for [mail] Laravel 5.4
Asked Answered
K

10

75

I am trying to show my markdown email on view, but there's something wrong on my mail view, it shows like

ErrorException in FileViewFinder.php line 112:
No hint path defined for [mail]. (View: /opt/lampp/htdocs/ppsb_new/core/resources/views/emails/tagihan.blade.php)

and my markdown mail view

@component('mail::message')
# TAGIHAN PEMBAYARAN

Berikut tagihan anda untuk pembayaran


@component('mail::button', ['url' => ''])
wut ?
@endcomponent

Gunakan kode tagihan tersebut untuk membayar tagihan.

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

and there's also vendor on my views who have their components.

Kulp answered 17/2, 2017 at 4:18 Comment(0)
J
175

You need to call the markdown() method in the build() method of your mailable - not the view() method. See the example below:

/**
 * Build the message.
 *
 * @return $this
 */
public function build()
{
    return $this->markdown('view-to-mail');
}
Jurist answered 17/2, 2017 at 18:27 Comment(6)
please give more elaborate answers e.g. using examples.Oolite
@Oolite check laracasts.com/series/laravel-from-scratch-2017/episodes/…Adallard
in which file you wrote that build method?Humoresque
@RidIslam in your mailable classRoturier
If dont want to use pre-shiped markdown then whats the solutionTerrific
To customise the pre-shipped markdown components, run this command to publish the components to your file system: php artisan vendor:publish --tag=laravel-mail. Docs here: laravel.com/docs/8.x/mail#customizing-the-componentsDaughterly
P
33

To use Markdown mailable messages, you have to update the build method of your Mailable class and instead of view(), you have to use markdown().

Like this:

public function build()
{
    return $this->markdown('emails.registered');
}
Pleasant answered 24/2, 2017 at 2:37 Comment(0)
S
4

if you have your email views in ...views/mail, that is how you can specify it:

app('view')->addNamespace('mail', resource_path('views') . '/mail');
Sugary answered 2/7, 2019 at 9:24 Comment(0)
K
3

If you have a View not found issue with laravel mail. After trying the accepted answer and it doesn't work, check yourtemplate.blade.php markdown file and ensure you are not closing @endcomponent twice without a opening @component

Kanara answered 25/3, 2018 at 6:38 Comment(0)
H
1

I had the same problem, then used this syntax and worked as a charm


@component('mail.html.message')
# Introduction

The body of your message.

@component('mail.html.button', ['url' => config('app.url')])
Button Text
@endcomponent

Thanks,<br>
{{ config('app.name') }}

@endcomponent

Where my folder structure views/mail/html for markdown messages.

and my App\Mail\NewEmail.php

<?php

namespace App\Mail;

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

class NewEmail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->markdown('mail.new-message'); // -> pointing to views/mail/new-message.blade.php containing above message
    }
}

Hinojosa answered 30/12, 2020 at 0:2 Comment(0)
S
0

If you want to use markdown in php blade file, then call view by markdown() Or if you want to call blade file by view(), remove markdown syntax from blade file and use plane html.

Satterfield answered 16/3, 2021 at 19:0 Comment(0)
O
0

I had same problem of "No hint path defined for [mail]." in laravel 10, I tried so many solutions from online but i cant solve it. at last this solution work for me.

In mailable class i have sendMarkdownMail.php so i do change in that content function

Before:

public function content(): Content
    {
        return new Content(
            view: 'emails.markdown',
        );
    }

After:

public function content(): Content
    {
        return new Content(
            markdown: 'emails.markdown', // Just change view to markdown.
        );
    }

also you should check that in view there is a vender->mail folder which email formats are present if it is not present then add this by artisan command:

php artisan vendor:publish --tag=laravel-mail
Oshiro answered 13/6, 2024 at 5:23 Comment(0)
D
0

Laravel is expecting HTML code and you're feeding it markdown.

I had the same error in my Laravel 11 app,

public function content(): Content
{
    return new Content(
        view: 'mail.user.new-primary-user-welcome-email',
        with: [...$data]
    );
}

My view had markdown code so I had the same error as you, when I changed view to markdown, it worked:

public function content(): Content
{
    return new Content(
        markdown: 'mail.user.new-primary-user-welcome-email',
        with: [...$data]
    );
}
Drury answered 10/7, 2024 at 13:16 Comment(0)
E
-1

Try using a custom email view template, like this:

You received a message from : {{ $name }}

<p>
Name: {{ $name }}
</p>

<p>
Email: {{ $email }}
</p>

<p>
Message: {{ $user_message }}
</p>
Enolaenormity answered 31/5, 2020 at 13:36 Comment(0)
R
-4

I used caffeinated/modules for laravel5.2.

If you are similar to me you can run this:

php artisan module:list
+------+-------+-------+-------------------------------------+----------+
| #    | Name  | Slug  | Description                         | Status   |
+------+-------+-------+-------------------------------------+----------+
| 9001 | Frame | Frame | this is a basic frame for both web. | Disabled |
| 9001 | Index | Index | this is web default index           | Enabled  |
| 9001 | Admin | Admin | This is admin of meixin project     | Enabled  |
+------+-------+-------+-------------------------------------+----------+

All right, you can see the disabled option.

php artisan module:enable Frame

Module is already enabled.

That's all, hope this helps.

Radke answered 6/1, 2018 at 2:42 Comment(1)
I know this didn't answer the question, but this solved my problem and I can't thank you enough.Euphonious

© 2022 - 2025 — McMap. All rights reserved.