0

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 }}        
Okay
  • 143
  • 2
  • 2
  • 10
  • can you display your email code? – Kevin Antala Sep 23 '16 at 05:34
  • Hi, I posted it in my question above –  Okay Sep 24 '16 at 17:11
  • first of all try to print $HTML_text_from_DB to check whether it has template or not and then try to print $data inside email.blade.php check what data is comming in. and try to give the direct view name in the first argument of the `Mail::send()` not the parsed data. – Kevin Antala Sep 26 '16 at 07:18

0 Answers0