How to send email by laravel?

1

I have the following routine implemented in Laravel

$prestadores = \App\Prestador::all();

Mail::send('emails.listaprestadores',['prestadores' => $prestadores],
   function($message) use ($prestadores){
       $message->to('[email protected]', 'Marcelo Gomes');
       $message->subject('[Teste] Lista de Prestadores');
});

The View is the code below. It does not generate exception , but the email is not sent. I changed the routine to send a simple email and it is sent normally. I think I'm doing something wrong while passing array , but I took the example in the Laravel documentation.

<!DOCTYPE html><html>
<head>
    <title>Lista de Prestadores</title>
</head><body>
<table width="900" class="table table-responsive table-striped">
    <thead>
        <th>ID</th>
        <th>Razão Social</th>
        <th>CNPJ</th>
        <th>Cidade</th>
    </thead>
    <tbody>
        @foreach($prestadores as $prestador)
            <tr>
                <td>{{ $prestador->id ]}</td>
                <td>{{ $prestador->rezao_social ]}</td>
                <td>{{ $prestador->cnpj ]}</td>
                <td>{{ $prestador->cidade ]}</td>
            </tr>
        @endforeach
    </tbody>
</table><table class="table">
<tr>
    <td><span class="small">TrabalhoEmDia.com - Suas tarefas em Dia - </span>/td>    
</tr>
</table>
</body>
</html>
    
asked by anonymous 12.11.2016 / 04:10

1 answer

1

The problem has been solved by including in% method of% o% with%.

Correct submission:

Mail::send('emails.listaprestadores',['prestadores' => $prestadores],function($message) use ($prestadores){
   $message->to('[email protected]', 'Marcelo Gomes');
   $message->subject('[Teste] Lista de Prestadores')
   $message->from('[email protected],'Marcelo');
});
    
12.11.2016 / 14:44