You click "Register" and the page hangs. One second, two seconds, three โ then the success message appears. Nothing is wrong with your code: the app was waiting for the SMTP server to accept the welcome email, and every user pays that wait on every request that sends mail.
Email is slow by nature. The SMTP conversation โ connect, authenticate, send, wait for confirmation โ takes one to three seconds on a good day, and much longer when the mail server is busy or unreachable. Inside a web request, that delay is added directly to your response time.
Laravel queues solve this cleanly. To send emails in Laravel without making the user wait, push a small job onto a queue and return immediately. A background worker picks the job up and talks to the SMTP server on its own time. The user never waits, and a slow mail server can no longer break your registration page. In this guide you will set up queued mail in Laravel 13 from scratch, with the mistakes that catch beginners along the way.
Why queued mail is worth the setup
Mail leaves the request, and three problems disappear:
- Response time. A registration that took 2.5 seconds drops to under 200 milliseconds, because the request only writes a row to the jobs table.
- Reliability. If the SMTP server is down for a minute, a queued job retries automatically instead of showing your user an error page.
- Scale. Ten thousand welcome emails become ten thousand small jobs a worker chews through steadily, instead of ten thousand slow requests on your web server.
The setup takes about ten minutes, and you only do it once per project.
Step 1: Pick a queue driver and create the jobs table
Laravel supports several queue drivers โ sync, database, redis, beanstalkd, Amazon SQS โ but the database driver is the right starting point. It needs no extra service, and you can switch to Redis later without changing any job code.
Set the driver in your .env file:
QUEUE_CONNECTION=database
Then generate the migration for the jobs table and run it:
php artisan queue:table
php artisan migrate
This creates a jobs table where Laravel stores queued jobs until a worker picks them up. Create the failed-jobs table too โ you will need it in step 5:
php artisan queue:failed-table
php artisan migrate
The classic beginner mistake is leaving QUEUE_CONNECTION on its default sync: jobs then run immediately inside the request, exactly like Mail::send() โ the queue exists in name only. If your mail still feels slow after this guide, check this line first.
Step 2: Make your Mailable implement ShouldQueue
This is the core of how you send emails in Laravel with queues: a Mailable becomes queued by implementing one interface โ ShouldQueue. Nothing else about the class changes:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class WelcomeMail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public function __construct(public $user) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Welcome to our app',
);
}
public function content(): Content
{
return new Content(
view: 'emails.welcome',
);
}
}
Two details matter. First, SerializesModels: Laravel stores only the model's id and re-fetches it fresh when the worker runs โ without it, the whole model is serialized and breaks if the model changes before delivery. Second, keep constructor data small โ pass a model or an id, never a big array or a file.
Step 3: Send it โ three ways, one result
With a ShouldQueue Mailable, even a plain send() call is queued automatically:
Mail::to($user->email)->send(new WelcomeMail($user));
The code reads like a synchronous send, but Laravel intercepts it and pushes a job instead. To bypass the queue for one specific send, use sendNow().
The other two methods say what they do more explicitly:
// Queue it now, worker sends it as soon as it can
Mail::to($user->email)->queue(new WelcomeMail($user));
// Queue it, but do not deliver before 10 minutes pass
Mail::to($user->email)->later(now()->addMinutes(10), new WelcomeMail($user));
later() is handy for reminders: "Your trial ends in three days" can be queued at signup and delivered exactly when it matters, with no cron job.
If the sending logic is bigger than one Mailable โ building a PDF attachment or fetching data from an API first โ put it in a dedicated Job instead:
php artisan make:job SendWelcomeEmail
class SendWelcomeEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct(public User $user) {}
public function handle(): void
{
Mail::to($this->user->email)->send(new WelcomeMail($this->user));
}
}
Dispatch it from your controller โ the response returns instantly:
SendWelcomeEmail::dispatch($user);
Step 4: Run a worker โ or nothing happens
This is the step people forget. A queued job just sits in the jobs table until a worker executes it โ start one with:
php artisan queue:work
The worker runs forever, picking up jobs one at a time. In development, use queue:listen instead โ it reloads your code on every job. In production, use queue:work, which is faster because it boots the framework once and keeps it in memory.
A long-running worker keeps the old version of your code after a deploy, so restart it after every deployment:
php artisan queue:restart
This signals all running workers to stop gracefully after their current job, so the next worker that starts loads the new code. Forgetting this is the number-one reason a "fixed" email bug keeps happening in production after the fix is deployed.
Useful flags: --tries=3 (retry limit), --timeout=90 (kill slow jobs), --sleep=3 (idle wait).
Step 5: Retries and failed jobs
A job that throws an exception is not lost. Laravel retries it โ with a growing delay โ until it hits the tries limit, then moves it to the failed_jobs table from step 1. Inspect the failures with:
php artisan queue:failed
Retry one specific failed job, or all of them, with:
php artisan queue:retry all
Or delete them once you have fixed the cause:
php artisan queue:flush
Before you retry everything blindly, read the exception stored with the failed job. Most failed mail jobs fall into three buckets: wrong SMTP credentials (every job fails the same way), a typo in the Mailable (retries will not help), or a temporary SMTP outage (retries fix it on their own). Retrying a credentials problem fifty times just sends fifty identical failures to your log.
Step 6: Keep the worker alive in production
A worker started in an SSH session dies the moment that session closes. On a real server, use Supervisor โ a small Linux process monitor that restarts your worker automatically if it crashes or the server reboots. A minimal config looks like this:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/your-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
numprocs=2
user=www-data
redirect_stderr=true
stdout_logfile=/var/www/your-app/storage/logs/worker.log
--max-time=3600 restarts each worker hourly, protecting you from slow memory growth in long-running PHP processes โ the same creep that ends in an allowed memory size exhausted fatal error.
On shared hosting without Supervisor, use the cron fallback: run the worker with --stop-when-empty every minute, so each tick processes whatever is waiting and then exits:
* * * * * cd /home/user/your-app && php artisan queue:work --stop-when-empty >> /dev/null 2>&1
Mail can wait up to a minute, but it needs no daemon and no root access.
Common mistakes and their fixes
| Mistake | What happens | Fix |
|---|---|---|
QUEUE_CONNECTION still sync |
Mail still sends inside the request | Set QUEUE_CONNECTION=database in .env |
| No worker running | Jobs pile up, no mail arrives | Run php artisan queue:work (or Supervisor) |
Mailable does not implement ShouldQueue |
send() talks to SMTP inside the request |
Add implements ShouldQueue to the Mailable |
| Worker not restarted after deploy | Old code keeps running | Run php artisan queue:restart on every deploy |
| Passing huge data into a job | Jobs table bloats, unserialize fails | Pass a model or an id, fetch the rest in handle() |
env() calls after config cache |
Silently falls back to sync |
Use config('queue.default'), never env() outside config files |
| No failed-jobs table | Failed jobs vanish | Run php artisan queue:failed-table and migrate |
Once you run php artisan config:cache in production, .env is no longer read at runtime. Any env('QUEUE_CONNECTION') call outside a config file returns null, and Laravel quietly falls back to sync โ your queue stops queueing, with no error anywhere.
Frequently asked questions
Do I need Redis for queued mail? No. The database driver handles welcome emails, password resets, and notifications for most small and medium apps. Move to Redis only when the jobs table becomes the bottleneck โ thousands of jobs per minute.
Can I use queues on shared hosting? Yes โ the cron fallback from step 6. A one-minute cron running queue:work --stop-when-empty is enough for most sites; no Supervisor or daemon needed.
What happens if the worker crashes mid-job? The job goes back to the queue and is retried, up to your --tries limit. Design handle() to be safe to run twice โ sending a welcome email twice is embarrassing; charging a card twice is not.
How do I test queued mail locally? Use the array mail driver or Mailtrap, keep QUEUE_CONNECTION=database, and run queue:work in a second terminal. Or set QUEUE_CONNECTION=sync in .env.testing so feature tests run jobs immediately.
Should every email be queued? Almost every one. The exception is mail the user is actively waiting for in the same request โ even then, a queued job with a running worker usually delivers within a second. If the reply must be instant and guaranteed, keep that one synchronous and queue the rest.
Conclusion
Queued mail in Laravel 13 is four pieces: the database driver and a jobs table, a Mailable that implements ShouldQueue, a worker that actually runs, and a plan for retries and failed jobs. Add Supervisor in production โ or the cron fallback on shared hosting โ and restart the worker on every deploy.
The payoff is immediate: requests stop waiting on SMTP, a mail outage stops breaking pages, and users get fast responses. If you are building the API that sends those emails, the same queue pattern works for any slow work โ the REST API tutorial shows the endpoints, and queues handle everything slow behind them.


