'Passing variables to email footer in Laravel
I would like to show a disclaimer in the footer saying
This email was sent to {recipients email address}.
but i can't figure out how i can get the email address into the standard footer blade.
Here is what I have: In my notification component I make the following call with $rcp_email having the email address of the recipient:
return (new MailMessage)
->subject('Contact Form Submitted')
->markdown('emails.generic.contactform', [
'first_name' => $this->first_name,
'message' => $this->message,
'rcp_email' => $this->rcp_email,
'url_security_issue' => $url_security_issue,
]);
The emails.generic.contactform looks like this
@extends('emails.main')
@section('content')
(body of email)
@endsection
emails.main looks like this
@component('mail::message')
@yield('content')
@if (isset($unsubscribe_url))
(html code for unsubscribe)
@endif
@endcomponent
the standard vendor\mail\html\message blade looks like this:
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.front_end_url'), 'logo' => asset('logo-image-white-circular-background.png')])
{{ config('app.name') }}
@endcomponent
@endslot
{{-- Body --}}
{{ $slot }}
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')
@endcomponent
@endslot
@endcomponent
I traced each level of blade and $rcp_email is first of all not availble in the message blade. I tried to pass it on by changing the first line of emails.main to
@component('mail::message', ['rcp_email' => $rcp_email])
but in either case when i try to use the variable in the message blade, i get the error Undefined variable: rcp_email
In an ideal case, I would want to add the html code and make use of the variable in the actual footer blade, but I don't know if that's possible.
I would much appreciate if there is any hints/any docus or articles you can share that describes in depth how this works?
Thanks, Goppi
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
