DEV Community

Cover image for Sending bulk emails in Laravel 10 using Mailgun
Lars Wolters
Lars Wolters

Posted on • Edited on

Sending bulk emails in Laravel 10 using Mailgun

Hi all,

I've been working on an example repository on how to send bulk emails using Mailgun in a Laravel 10 application. It demonstrates how to use a traditional Markdown email with the Mailgun bulk email sending feature, and how to add both recipient-specific data and shared data in the emails.

The problem with queueing bulk emails is that you can't use the Mail::queue() method because it will create a new job for each email. This will cause the queue to grow very fast and eventually crash.

A solution to this problem is to make use of the Mailgun API. Mailgun allows you to send up to 1000 emails per batch. This means that you can send 1000 emails with a single API call.

https://github.com/larswolters98/laravel-mailgun-bulk-emails-example

To read more articles I wrote, you can visit my website: https://larswolters.dev

Thanks,

Lars

Top comments (0)