How to customize/change the header logo of notification mail (laravel)
Asked Answered
I

2

8

I have no idea where could I found the header logo example below(squared):

enter image description here

My content code:

public function toMail($notifiable)
{
    return (new MailMessage) 
        ->line('The introduction to the notification.'.$user->name)
        ->line('Hey Now hey now')
        ->action('Notification Action', route('register.select'))
        ->line('Thank you for using our application!');
}


EDITED: in email.blade.php:
@component('mail::message')
{{-- Greeting --}}
@if (! empty($greeting))
# {{ $greeting }}
@else
@if ($level === 'error')
# @lang('Whoops!')
@else
# @lang('Hello!')
@endif
@endif

{{-- Intro Lines --}}
@foreach ($introLines as $line)
{{ $line }}

@endforeach

... and so on, and so forth


I want to customize that logo header, my problem I can't find where exactly. Need your help Sirs.
Insurgent answered 15/4, 2019 at 21:15 Comment(0)
C
27

You just have to customize mail templates.

Run this command:

php artisan vendor:publish --tag=laravel-notifications

After that you'll find templates in resources/views/vendor/notifications.


If you want to customize mail components used in templates:

php artisan vendor:publish --tag=laravel-mail

You'll find components in resources/views/vendor/mail. The ones you want are message.blade.php and header.blade.php.

Conrad answered 15/4, 2019 at 21:25 Comment(5)
thanks Sir. I got the template which is email.blade.php but I can't find the part I want to customize.Insurgent
I edited my post. can you help me Sir where the logo header partInsurgent
@escbooster12 Updated my answer.Conrad
that header.blade.php is the answer. Thanks Sir.Insurgent
This doesn't work for me. Updated the header for logo but no luck.Belomancy
C
6

It only shows the Laravel logo if the APP_NAME in the .env is set as "Laravel".

So once you change this setting it will omit the default logo. if you want to change it to display something else you can publish the mail components as other answers showed and customize it.

Cardon answered 13/8, 2021 at 9:14 Comment(1)
I already knew I had to do this, but needed to hear it from somebody else to be sure thanks!Fustigate

© 2022 - 2024 — McMap. All rights reserved.