laravellaravel-5.8

How can I put an image in my email markdown header?


I am trying to replace the app name in a Laravel markdown email header with an image but I am not having a lot of success.

message.blade.php

@component('mail::layout')
{{-- Header --}}
@slot('header')
    @component('mail::header', ['url' => config('app.url')])
        @if(config('app.site.logo'))
            <img src="{{ url(config('app.site.logo')) }}" class="site- 
logo" height="50" />
        @else
            {{ config('app.site.name', 'Campaign') }}
        @endif
    @endcomponent
@endslot

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

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

{{-- Footer --}}
@slot('footer')
    @component('mail::footer')
        &copy; {{ date('Y') }} {{ config('app.site.name', 'Campaign') }}. 
@lang('All rights reserved.')
    @endcomponent
@endslot
@endcomponent

followup.blade.php <-- email markdown page

@component('mail::message')
 ## Follow up reminder

Set for today {{ date('l \t\h\e jS \of F Y', strtotime($member->FollowUp)) }} with  {{$member->LastName}} {{$member->FirstName}} / {{$member->Position}}

@component('mail::panel', ['url' => ''])
@if(count($member->notes))

*notes...*
@foreach($member->notes->sortByDesc("created_at") as $note)

**{!! nl2br(e($note->note)) !!}** 

by *{{$note->user->name}}.*

@endforeach

@else
 No notes added for member
@endif
@endcomponent
Probable Vote: {{$member->LikelyVote}}
@component('mail::button', ['url' => $the_url])
View Information
@endcomponent


 Thank you,
{{ config('app.site.name', 'Campaign application A.I.') }}
@endcomponent

Everything works on mailtrap and the header image shows up. The image does not show up in gmail.


Solution

  • Original Question - How to get rid of "Laravel" in the header

    Set the App Name

    In your .env set the

    APP_NAME="YOUR APPLICATIONS NAME"
    

    Which is where the Laravel in the header is coming from.

    Or Modify the Template

    You can have more control by publishing the source for the markdown mailables by running:

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

    And editing them at resources/views/vendor/mail

    Images

    The way to include images from your server is:

       ![Some option text][logo]
    
       [logo]: {{asset('/img/official_logo.png')}} "Logo"
    

    Otherwise, you can get the base64 encoding and drop that into an img tag to truely embed the image (after reading it into a variable (image)):

    <img src="data:image/jpg;base64,{{ base64_encode($image) }}">