I am using Mail::send() Laravel 5.2 with a email.blade.php as param which gets its html-content dynamically from the database before. After sending the email arrived empty.
But if I put the HTML-content directly into the email.blade.php, it works fine.
How could I do it with the database?
*** Edit:
Now it work a little bit. But the ID template still has not been replaced with the id value.
// From database
<table width="100%">
<tr>
<td></td>
<td>
Your ID: {{ $data->your_id }}
</td>
<td></td>
</tr>
</table>
// email.blade.php
{{ $data->mailtext_DB }}
// Call Mail::send
$data = [
'sender_email' => 'info@google.com',
'mailtext_blade' => email,
'sender_name' => 'Google',
'receiver_email' => 'user@google.com',
'receiver_name' => 'User One',
'subject' => 'Hello User!',
'mailtext_DB' => $HTML_text_from_DB, // this comes from the database
'your_id' => $id_no
];
// convert $data to an object for use in Mail::send
// ...
$status = Mail::send(
$data->mailtext_blade,
[ 'data' => $data ],
function ( $m ) use ( $data ) {
$m->from( $data->sender_email, $data->sender_name );
$m->to( $data->receiver_email, $data->receiver_name )->subject( $data->subject );
}
);
The content of the email I received is: Your ID: {{ $data->your_id }}
But I am expecting: Your ID: 123546
The difficulty is that the view should be small like:
// email.blade.php
{{ $data->mailtext_DB }}