I’m working with Laravel 5.5 and Mailgun to send marketing emails to a large group of subscribers. My current list has around 700 people but I expect it to grow to several thousand soon.
Right now I’m using a simple foreach loop to send emails one by one, but this approach is causing problems. Only about 530 emails actually get delivered out of the 700 I’m trying to send. The rest just don’t go through for some reason.
I’ve been looking online for better ways to handle bulk email sending but haven’t found clear explanations that work for my situation. Does anyone know the right approach to make sure all emails in a large campaign actually get sent?
public function sendBulkEmails()
{
// Retrieve subscriber data from API
$subscribers = json_decode($response->getBody());
$siteUrl = config('app.site_url');
foreach($subscribers as $index => $subscriber){
Mail::to($subscriber)
->send(new CampaignEmail($data, $subscriber, $siteUrl));
}
$result = ['status' => 'Campaign sent successfully'];
return response()->view('campaigns.result', $result, 200);
}