Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

julianov's avatar

Send email in laravel to multiple recipients. more than 10000

Hello All.

This is how I implements the email sends in laravel:

The way to send emails to multiple users that I have implemented is as follows.

$usuarios = User::all();
$result_code = '123456'; 

foreach ($usuarios as $usuario) {
    Mail::to($usuario->email)
    ->queue((new EmailConfirmation($usuario, $result_code))
        ->from('[email protected]', 'xxxxxx xxxxxx - xxxxxx xx xxxx xxxxxx')
        ->subject('Subject'));
}

The problem is that I may find that I have to send 10,000 emails to different mailboxes. Is it the best way to implement it? Or can I send them all together in the same email, where each imail address would go in CC?

Also, how could I detect a shipment problem during the shipping time?

0 likes
2 replies
Snapey's avatar

I doubt your email provider will allow you to send 1000's of emails as one message

Besides, you should NEVER send to multiple un-related recipients with the TO or CC fields. Someone is bound to REPLY-ALL

Have a look at Amazon SES. It has one of the lowest message costs and you can create a template and then send it a list of email addresses to send to.

If you are doing this because today you have 5 users but think in the future you might have 1000's, wait until you have a problem.

1 like
julianov's avatar

@Snapey The way I implement it. Do you ship one by one? Couldn't this cause delay in the main thread?

$usuarios = User::all();
$result_code = '123456'; 

foreach ($usuarios as $usuario) {
    Mail::to($usuario->email)
    ->queue((new EmailConfirmation($usuario, $result_code))
    ->from('[email protected]', 'xxxxxx xxxxxx - xxxxxx xx xxxx xxxxxx')
    ->subject('Subject'));
}

Please or to participate in this conversation.