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

poldixd's avatar

Modify the header and footer in mail markdown mails

Hello,

I'm trying to run the new laravel markdown mails. My blade template is:

@component('mail::message')
# {{ $Subject }}

Hallo {{ $user->name }},

I'm a mail message.

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


@endcomponent

The result is this:

Image of the mail

But how can i define the header or footer? I will put a logo in the header.

Greetings

0 likes
15 replies
tykus's avatar

You need to publish the vendor files (php artisan vendor:publish) for Laravel's email templates, and edit the header and footer components in the resources/views/vendor/mail/markdown/message.blade.php file.

7 likes
poldixd's avatar

Hey @tykus, thanks for your answer.

I had published the vendor files, but i didn't know, if it was the right way.

There is are a header and footer slot section in resources/views/vendor/mail/markdown/message.blade.php...

Can i overwrite the section in my mail blade template without editing the resources/views/vendor/mail/markdown/message.blade.php file?

Greetings

poldixd's avatar
poldixd
OP
Best Answer
Level 2

ok, i've found the solution. You don't have to use @component('mail::message')... you must use @component('mail::layout') in the template.

Here is my mail:

@component('mail::layout')
    {{-- Header --}}
    @slot('header')
        @component('mail::header', ['url' => config('app.url')])
            <!-- header here -->
        @endcomponent
    @endslot

    {{-- Body --}}
    <!-- Body here -->

    {{-- Subcopy --}}
    @slot('subcopy')
        @component('mail::subcopy')
            <!-- subcopy here -->
        @endcomponent
    @endslot


    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            <!-- footer here -->
        @endcomponent
    @endslot
@endcomponent

38 likes
Jam0r's avatar

Update on this.

Once I have published the vendor email files, even when I change the header in message, it does not take effect when the email is sent?

MacPhil's avatar

@edit:

i changed resources/views/vendor/mail/html/message.blade.php and it shows even with the Markdown function

The Markdown path is for Text Format

https://github.com/laravel/framework/issues/17970#issuecomment-281121329

@endedit

the same as JamOr,

  {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
<!-- change something but nothing happens -->
            © {{ date('Y') }} MyComp

        @endcomponent
    @endslot

Theme settings are like this in config/mail.php

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

    'paths' => [
        resource_path('views/vendor/mail'),
    ],
],
1 like
cutups's avatar

I'm looking at editting the contents of my footer of my markdown email.

I published the templates and have a message.blade.php that i can edit.

But none of the public properties in my Mailer class are available in that template.

How can I pass data in?

I tried to user with, but that did not work. The updated footer section of my message.blade.php looks like this (need to pass in vars such as $site, $url, $user.

{{-- Footer --}}
@slot('footer')
@component('mail::footer')
You received this email because you signed up for email notifications email from {{ $site }}
however, you may [unsubscribe]({{$url}}users/{{$user->id}}) from this list or view our [Privacy Policy]({{$url}}privacy) for more information.
© {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')
@endcomponent
@endslot
@endcomponent
4 likes
Juukie's avatar

Run php artisan vendor:publish --tag=laravel-mail and you have the files under views/vendor/mail

1 like

Please or to participate in this conversation.