Answer the question
In order to leave comments, you need to log in
Why does the MAIL facade take a long time to complete in Laravel 5.2?
Good time everyone!
Why does the script slow down (the page reloads for a long time) when using Mail?
If you remove the Email sender from the code, then the code works many times faster
use Illuminate\Support\Facades\Mail;
$text = 'some text in DB';
$title = 'some title';
$userEmail = 'some user email';
Mail::send('emails.send_mail', ['text' => $text], function ($message) use ($userEmail, $title) {
$message->from('[email protected]' , 'Sender Name');
$message->to($userEmail)->subject($title);
});
How to solve such braking? Who will advise what?
Answer the question
In order to leave comments, you need to log in
This is not a facade that slows down, but in principle, sending an email is not a quick thing. If you want to do it quickly, then send email through queues.
laravel.su/docs/5.0/mail#queueing-mail
Another service for sending email via api (mandril, mailchimp). The API works quickly, and the message is queued for sending already on the service itself
Use queues. Create queue on Mail, and Job on sending. Actually you add to queue and further all by itself. The main thing is not to forget to run it). It lags because the sending works synchronously - until it is sent, the server will not respond until that time. It is not necessary to do so.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question