Problem sending mail from laravel

0

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?

    
asked by JG_GJ 07.11.2017 в 06:56
source

1 answer

0

Surely as you use mail as a driver, your mail is incorrectly configured on the server. Did you try to send an email from the terminal?

    
answered by 07.11.2017 в 16:50