Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.4 mail messages how to edit header and footer

Hi I am trying to use MailMessage function in my Laravel App. My question is very simple. How to edit the Header and the Footer when receiving email from the app? Here is the picture below.

enter image description here

I want to change the header Laravel from my App name and the Hello with a Hello $user->name and the Regards, with my App name also and the footer below to the App name also.

enter image description here

I tried to change the `

resources/views/vendor/mail/markdown/message.blade.php

To:

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

    {{-- Body --}}
    {{ $slot }}

    {{-- Subcopy --}}
    @isset($subcopy)
        @slot('subcopy')
            @component('mail::subcopy')
                CCTV Team
            @endcomponent
        @endslot
    @endisset

    {{-- Footer --}}
    @slot('footer')
        @component('mail::footer')
            © {{ date('Y') }} CCV3. All rights reserved.
        @endcomponent
    @endslot
@endcomponent

But not working when I send a reset password request Would really appreciate if someone can help me. Thanks in advance.

`

like image 451
Jaaayz Avatar asked Aug 29 '17 01:08

Jaaayz


1 Answers

I want to change the header Laravel from my App name and the Hello with a Hello $user->name and the Regards, with my App name also and the footer below to the App name also

Mailable Markdown by default has the config('app.name') that picks the APP_NAME from your .env file. So by modifying the APP_NAME will effect on your markdown template.

OR if you modifying it manually, run the following command on your terminal
php artisan vendor:publish --tag=laravel-mail and go to the resources/views/vendor/mail/html/message.blade.php and modify the header and footer slot.

For changing Hello to Hello {user_name}, there is markdown called greeting() method that holds Hello!, you can change it whatever you want.

For Regards run this command on your terminal
php artisan vendor:publish --tag=laravel-notifications and go to the resources/views/vendor/notifications/email.blade.php and modify the Regards whatever you want.

To know more in details take a look on customizing markdown email.

like image 70
jogesh_pi Avatar answered Oct 25 '22 18:10

jogesh_pi