Lars Wolters

Lars Wolters

Software developer & writer

Back to posts
Jul 11 2023

Sending bulk emails in Laravel 10 using Mailgun

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

If you have any questions or feedback, feel free to reach out to me.

Thanks,

Lars

I'm available for freelance development work 🚀

If you are looking to have a website or web application built, feel free to reach out to me.

Copyright © 2024 Lars Wolters Software KVK 78342392 BTW NL003321256B95