lundi 28 août 2017

Laravel mail queue not posting to mailtrap

I've been trying to make Laravel's Queuing work for hours and to no avail I have not Idea what's going on; I think the queues are working since they are posting to the database but what I don't understand is why aren't they executing and posting to mailtrap.

I've set my .env file to database

QUEUE_DRIVER=database

My controller:

$mailQueue  =   (new SendNotification($contact))
                     ->delay(5);

dispatch($mailQueue);

My Send Notification Job:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

use Mail;
use App\Mail\Notification;

class SendNotification implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $contact;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($contact)
    {
        $this->contact  =   $contact;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $notification   =   (new Notification($contact));

        Mail::to('cryptic_sentinel@hotmail.com')
                ->queue($notification);
    }
}

Finally, my Mailable:

<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Notification extends Mailable
{
    use Queueable, SerializesModels;


    protected $contact;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($contact)
    {
        $this->contact  =   $contact;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {

        return $this->view('mail.notify')
                    ->with([
                        'notifyName'    =>   $this->request->name,
                        'notifySubject' =>   $this->request->subject
                    ]);
    }
}

Pretty basic really, but I don't understand why its not posting or sending to Mail trap; although my Jobs table is filled with Queues that won't post.

Has anyone ever had this problem? if so anyone know what the solution is - I tried php artisan queue:work and php artisan queue:listen but they don't post anything out on terminal.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wX5e7F
via IFTTT

Aucun commentaire:

Enregistrer un commentaire