I have the following configuration in the .env file
MAIL_DRIVER=mail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=********
MAIL_ENCRYPTION=ssl
and my driver in the following way:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Parqueos;
use App\Mail\ComentariosParqueos;
use Mail;
class ParqueosController extends Controller
{
public $message = "";
public $result = false;
public $records = array();
public function EnviarComentario()
{
try
{
$data = [];
Mail::send('mails.ComentariosParqueos', $data, function ($message){
$message->subject('Comentario');
$message->to('[email protected]');
});
$statusCode = 200;
$this->message = "Correo enviado correctamente";
$this->result = true;
}
catch (\Exception $e)
{
$statusCode = 200;
$this->message = $e->getMessage();
}
finally
{
$response =
[
'message' => $this->message,
'result' => $this->result,
'records' => $this->records
];
return response()->json($response, $statusCode);
}
}
}
when executing the method returns the following:
{
"message": "Correo enviado correctamente",
"result": true,
"records": Array[0][
]
}
But it turns out that it does not send anything in the view I only have html in order to test if the mail arrives.
What could be my mistake?