I just want to queue an email when an user registers. So I do this when the user posts the registration form:
Mail::queue('emails.activate', $data, function($message) use ($user)
{
$message->from('[email protected]', 'Mysite.com');
$message->to($user->email, $user->username)->subject('Welcome');
});
The queue listener is running (php artisan queue:listen) and a supervisor process make sure it will restart if stopped.
It works, the user get the email but the HTTP response when registering is very slow, exactly as I would expect it to be if I was trying to directly send the email. If I comment all the queuing code above, the HTTP response time is just fine.
I use the sync driver in queue.app:
'default' => 'sync',
'connections' => array(
'sync' => array(
'driver' => 'sync',
),
etc...
At last, I run my own private server (Ubuntu) with postfix. Can someone help me figure out why the response is so slow while I'm queuing the email?
The sync driver runs its queued jobs just before Laravel ends its execution. That is why it is called the sync driver, you will need to change it to achieve desired functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With