I promise this is not just another Mail::queue newbie question. I had Laravel 4.2 app working with Iron.io Push queues Then, I upgraded to Laravel 5.1 and my Mails just stopped working. I have UserController from which I send user account verification email to the registrant.
//Used for Mail
$data=['msg'=>$msg];
$details=array(
'email'=>$email,
'name'=>$name,
'subject'=>$subject,
'msg'=>$msg);
\Mail::queue(['text'=>'emails.contactus'],$data,
function($message) use ($email,$name,$subject) {
$message->from($email,$name);
$message->to(Config::get('app.site_support'))->subject($subject);
});
Iron.io is configured properly with keys and such. My Mail queuing app and queue processing apps are different.
Error I get is
[2015-10-19 18:12:32] production.INFO: Queue POST Item received
[2015-10-19 18:12:32] production.ERROR: exception 'ErrorException' with message 'Class 'UserController' not found' in /var/www/app/vendor/jeremeamia/SuperClosure/src/SerializableClosure.php:130
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Class 'UserCont...', '/var/www/app...', 130, Array)
#1 /var/www/app/vendor/jeremeamia/SuperClosure/src/SerializableClosure.php(130): Closure->bindTo(NULL, 'UserController')
#2 [internal function]: SuperClosure\SerializableClosure->unserialize('a:5:{s:4:"code"...')
#3 /var/www/app/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(300): unserialize('C:32:"SuperClos...')
#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(286): Illuminate\Mail\Mailer->getQueuedCallable(Array)
Looks like Mail::queue is serializing UserControl which is not available in queue/receive processor app. I tried placing UserController in processor app but still get the same error
So this is just for another poor soul who's facing the same issue. After a lot of searching I resorted to a separate Job class that sends email and takes $data (for view template data) and $details (specifying email template, 'to' email address and subject) in its constructor
Then I Mail::send in handle method.
I fire this job using Controllers $this->dispatch method just as they said in Laravel Documentation
After updating Laravel from 4.2 to 5.1 you need to update the IronMQ version to "4.*" in composer.json. Laravel 5.1 is only compatible with IronMQ v4.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.