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

eggplantSword's avatar

How to add logo to Default Laravel Mail Template

I have published the laravel-mail in order to be able to change the default mail templates and I want to add a logo or picture to the header but I've been unsuccessful. This is what I've tried in the views/vendor/mail/html/header.blade.php. Both ways I've tried show nothing it's just empty and I get two 500 Server Errors, how can I do this?

<tr>
    <td class="header">
        <img src="{{asset('public/images/logo.png')}}" alt=""/>
        <img src="../../../../../public/image/logo.png" alt="">
    </td>
</tr>

Right now I'm sending the email like this is the routes only to be able to see it in order to change what I want

Route::get('/email', function () {
        Mail::to('[email protected]')->send(new WelcomeMail());
        return new WelcomeMail();
    });

This is how I would send this particular email (welcome email)

Mail::to($dbUser->email)->send(new WelcomeMail());

I creating a Mail Class called WelcomeMail where it has the default setup

class WelcomeMail extends Mailable
{
    use Queueable, SerializesModels;
    
    public function __construct()
    {
        //
    }

    public function build()
    {
        return $this->markdown('emails.welcome');
    }
}
0 likes
4 replies
warpig's avatar

This worked out for me, in Laravel 8 this is how it's displayed:

<tr>
<td class="header">
<a href="{{ $url }}" style="display: inline-block;">
@if (trim($slot) === 'Laravel')
<img src="https://laravel.com/img/notification-logo.png" class="logo" alt="Laravel Logo">
@else
{{ $slot }}
@endif
</a>
</td>
</tr>

And this is how it worked for me:

<tr>
<td class="header">
<a href="{{ $url }}" style="display: inline-block;">
@if (trim($slot) === 'Laravel')
<img src="https://laravel.com/img/notification-logo.png" class="logo" alt="Laravel Logo">
@else
<img src="{{ asset('images/my-logo.png') }}" class="logo" alt="My logo">
@endif
</a>
</td>
</tr>

As you can see there is a conditional statement checking if the app name is equal to Laravel, change the name of your app from the env file and then remove the {{ $slot }} and use your own path. You need to change the app name so that it skips the first portion of the statement and selects the space between the @else.

1 like

Please or to participate in this conversation.