Reputation: 485
i'm unable to queue emails in laravel 5.4. in previous laravel 5.3 projects all worked fine.
Send is still working:
Mail::send('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message)
{
$message->from('[email protected]', 'test');
$message->to('[email protected]');
});
Queue does not work:
Mail::queue('email.blank', ['title' => 'nice', 'content' => 'message'], function ($message)
{
$message->from('[email protected]', 'test');
$message->to('[email protected]');
});
With the following error:
InvalidArgumentException in Mailer.php line 314:
Only mailables may be queued.
in Mailer.php line 314
at Mailer->queue('email.blank', array('title' => 'nice', 'content' => 'message'), object(Closure)) in Facade.php line 221
at Facade::__callStatic('queue', array('email.blank', array('title' => 'nice', 'content' => 'message'), object(Closure))) in EmailController.php line 16
at EmailController->mailtest()
at call_user_func_array(array(object(EmailController), 'mailtest'), array()) in Controller.php line 55
at Controller->callAction('mailtest', array()) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(EmailController), 'mailtest') in Route.php line 203
at Route->runController() in Route.php line 160
at Route->run() in Router.php line 559
at Router->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 30
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in SubstituteBindings.php line 41
at SubstituteBindings->handle(object(Request), object(Closure)) in Pipeline.php line 148
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 53
I've created the queue table by
php artisan queue:table
php artisan migrate
and changed the driver to database
UPDATE it looks like in laravel 5.4 you are only able to queue emails using mailables
php artisan make:mail TestMail
within the newly created class change the build function to return an existing view e.g
public function build()
{
return $this->view('email.test');
}
then queue the mail
Mail::to('[email protected]')->send(new TestMail());
thanks
Upvotes: 2
Views: 6659
Reputation: 97
the queue email is use this script
Mail::to('[email protected]')->queue(new TestMail());
instead of
Mail::to('[email protected]')->send(new TestMail());// this just commonly sent email not queueing
Upvotes: 1