I want to show loading image or bar while server is taking time to send the email to the specified user in laravel. Is there any laravel package to do so?
You should use queues for that. From the docs :
Since sending email messages can drastically lengthen the response time of your application, many developers choose to queue email messages for background sending. Laravel makes this easy using its built-in unified queue API. To queue a mail message, use the
queue
method on the
Mail::to($request->user())
->cc($moreUsers)
->bcc($evenMoreUsers)
->queue(new OrderShipped($order));
// check for failures
if (Mail::failures()) {
// return response showing failed emails
}else{
return response()->json(['status'=>201],201);
}
//in you ajax function probably!
$('#sendEmailBtn').click(function(e){
showLoadingImage();
$.ajax({
url:url,
data:data,
success:function(response){
if(response == 201){
stopLoadingImage();
}
}
});
});
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.