Support the ongoing development of Laravel.io →
Mail Queues Jobs

in my controller:

$order = Order::with('address','slot','products')->first(); Mail::to('abc@email.com') ->send(new OrderPlaced($order));

and in my OrderPlaced class:

class OrderPlaced extends Mailable { use Queueable, SerializesModels;

/**
 * The order instance.
 *
 * @var Order
 */
public $order;

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

}

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


    return $this->from('cs@xxx.com','My name')
        ->subject('Order #'.$this->order->id)
            ->view('emails.orders.placed');


}

} above code works awesome. however, when i put to queue by change the class OrderPlaced

class OrderPlaced extends Mailable implements ShouldQueue { use Queueable, SerializesModels;

/**
 * The order instance.
 *
 * @var Order
 */
public $order;

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

}

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


    return $this->from('cs@xxx.com','My name')
        ->subject('Order #'.$this->order->id)
            ->view('emails.orders.placed');


}

}

And got error from table failed_jobs: InvalidArgumentException: Invalid view. in /var/www/myapp/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php:379

Last updated 3 years ago.
0

I've just resolved the similar issue. Without using a queue everything worked all right, but when I added ShouldQueue to my class responsible for the sending of email I received the same exception. In my case there was a call to helper request() in function build(). Instead of this, I should have used dependency injection to pass the necessary data to this class, which is suggested by documentation. Maybe, this will help

0

Sign in to participate in this thread!

Eventy

Your banner here too?

razor9999 razor9999 Joined 22 Feb 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.