Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jarcas's avatar
Level 1

Notifications that use ->markdown in toMail() don't show the view specified or contents, just the theme layout

I'm using Laravel 10 (I know, I'm working on updating) and for some reason emails sent from any notification that use markdown don't have any contents in the email other than the theme's layout - the view specified in the method doesn't show up. This is true for both an existing markdown notification email, and a brand new one.

To test, I ran

php artisan make:notification InvoicePaid --markdown=mail.invoice.paid

The InvoicePaid.php file's mail method:

    public function toMail($notifiable)
    {
        return (new MailMessage)->markdown('mail.invoice.paid');
    }

And then added a route:

    Route::get("/sendtestemail", function () {
        $user = \App\Models\User::find(1);
        $user->notify(new \App\Notifications\InvoicePaid());
    });

And it does the same thing.

My config/mail.php:

    'markdown' => [
        'theme' => 'default',

        'paths' => [
            resource_path('views/vendor/mail'),
            resource_path('views/vendor/mail/html'),
            resource_path('views'),
        ],
    ],

I'm at my wit's end here, what's going on? The notification gets added to the database correctly when using toDatabase, but toMail's markdown method just doesn't work right. The email gets sent, but it's just the theme's layout and the view specified ("mail.invoice.paid") doesn't get included.

0 likes
10 replies
tisuchi's avatar

@jarcas Can you share your markdown view file (mail.invoice.paid)?

Also, ensure your Markdown components are aligned without leading spaces or tabs!

jarcas's avatar
Level 1

@tisuchi Sure:

<x-mail::message>
# Introduction

The body of your message.

<x-mail::button :url="''">
Button Text
</x-mail::button>

Thanks,<br>
{{ config('app.name') }}
</x-mail::message>
tisuchi's avatar

@jarcas It looks good! I assume that your markdown file does not have any indentation or tab (at least I don't see).

Usually, if Laravel thinks the view is empty or malformed, it will render only the theme layout. Just to test, can you try with:

RAW TEXT TEST ABOVE
<x-mail::message>
# It works!
@endcomponent

If RAW TEXT TEST ABOVE doesn't show up — something's broken at the view level.

jarcas's avatar
Level 1

@tisuchi No indentation or tabs, and I tried your code and it doesn't work

tisuchi's avatar

@jarcas It seems wired!

Did you clear the view and config cache?

php artisan view:clear
php artisan config:clear
php artisan cache:clear
jarcas's avatar
Level 1

@tisuchi Cleared everything and still nothing. How can I debug where the problem is?

tisuchi's avatar

@jarcas There could be multiple ways!

I believe the app is not using your Markdown View.

In your route, just check like this way:


Route::get('/preview-email', function () {
    $notification = new \App\Notifications\InvoicePaid();
    $mail = $notification->toMail(\App\Models\User::first());
    dd([
        'view' => $mail->markdown,
        'html' => $mail->render(),
    ]);
});

Check:

  • The view should be mail.invoice.paid
  • The HTML should contain Your invoice has been paid (your Markdown content)
jarcas's avatar
Level 1

@tisuchi dd() seems to output the correct information - the view variable is "mail.invoice.paid" and the HTML is the correct HTML, the view is rendered correctly in it.

tisuchi's avatar

@jarcas It's strange behaviour to me!

Have you checked this already? https://stackoverflow.com/a/54846029

In the markdown file mail.invoice.paid, can you set some button value instead of empty? Sometimes it may create issues!

<x-mail::button :url="'https://example.com'">
jarcas's avatar
jarcas
OP
Best Answer
Level 1

@tisuchi Thanks for all your help, but I tracked it down.

I decided to go through my composer.json and look at the issues for each package, and found this. Sadly it looks like a package that I need and is causing the issue. I'll have to switch away from using Markdown in the email.

Thanks again!

Please or to participate in this conversation.