{"id":20327,"date":"2025-08-29T00:00:00","date_gmt":"2025-08-29T00:00:00","guid":{"rendered":"https:\/\/www.mailgun.com\/blog\/envoi-emails-masse-gestion-files-attente\/"},"modified":"2026-09-15T10:04:46","modified_gmt":"2026-09-15T10:04:46","slug":"envoi-emails-masse-gestion-files-attente","status":"publish","type":"blog","link":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/","title":{"rendered":"Optimiser l&rsquo;envoi d&#8217;emails en masse par la gestion personnalis\u00e9e des files d&rsquo;attente avec l&rsquo;API de Mailgun"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Sending bulk emails requires quite a bit of finesse and care. Several factors add to the complexity, including throttling and rate limits set by mailbox providers to control the flow of emails, data protection laws that must be adhered to, and deliverability issues caused by invalid addresses or duplicates. On top of that, you need to manage SMTP connection thresholds, provider-imposed limits, and unexpected delays.<\/p>\n\n<p class=\"wp-block-paragraph\">Fortunately, these challenges can be navigated. This guide will show you how to use Mailgun&rsquo;s API as your conductor&rsquo;s baton to streamline bulk email sending while avoiding common pitfalls. But first, let&rsquo;s explore why these issues happen in the first place \u2013 and why they can derail your bulk email campaigns.<\/p>\n\r\n    <nav data-content-type=\"longform\" class=\"toc-block longform-spacings px-5 py-6 px-md-6 px-lg-7 py-md-7 bg-light fs-sm rounded-lg\" aria-labelledby=\"toc-title-6464\"><p class=\"h5 m-0\" id=\"toc-title-6464\">Table des mati\u00e8res<\/p><div class=\"d-flex mt-3\"><div class=\"w-auto fw-bold text-accent d-flex me-2\">01<\/div><div class=\"d-flex flex-column\"><a class=\"fw-bold scrollme link-body-color text-accent\" href=\"#the-challenges-of-sending-bulk-emails\">The challenges of sending bulk emails<\/a><\/div><\/div><div class=\"d-flex mt-3\"><div class=\"w-auto fw-bold text-accent d-flex me-2\">02<\/div><div class=\"d-flex flex-column\"><a class=\"fw-bold scrollme link-body-color text-accent\" href=\"#how-queues-can-help\">How queues can help<\/a><\/div><\/div><div class=\"d-flex mt-3\"><div class=\"w-auto fw-bold text-accent d-flex me-2\">03<\/div><div class=\"d-flex flex-column\"><a class=\"fw-bold scrollme link-body-color text-accent\" href=\"#streamlining-bulk-email-sending-with-queues-and-mailgun\">Streamlining bulk email sending with queues and Mailgun<\/a><a class=\"scrollme link-body-color\" href=\"#select-your-queuing-solution\">Select your queuing solution<\/a><a class=\"scrollme link-body-color\" href=\"#architecture-overview\">Architecture overview<\/a><a class=\"scrollme link-body-color\" href=\"#create-your-queues\">Create your queues<\/a><a class=\"scrollme link-body-color\" href=\"#consume-your-queues-and-send-your-messages\">Consume your queues and send your messages<\/a><\/div><\/div><div class=\"d-flex mt-3\"><div class=\"w-auto fw-bold text-accent d-flex me-2\">04<\/div><div class=\"d-flex flex-column\"><a class=\"fw-bold scrollme link-body-color text-accent\" href=\"#conclusion\">Conclusion<\/a><\/div><\/div><\/nav>\n<h2 class=\"wp-block-heading\">The challenges of sending bulk emails<\/h2>\n\n<p class=\"wp-block-paragraph\">Rate limits and throttling set by email service providers (ESPs) tend to be the most common culprits behind bulk email deliverability issues. Beyond provider-imposed thresholds, your <a href=\"https:\/\/www.mailgun.com\/fr\/blog\/deliverability\/ameliorer-reputation-expediteur\/\" target=\"_tabs\" rel=\"noopener noreferrer\">sender reputation score<\/a> also plays an important role. Launching a mass email campaign without verifying your score and understanding ESP-specific limits can quickly degrade your reputation.<\/p>\n\n<p class=\"wp-block-paragraph\">A declining sender score creates a negative feedback loop, where each bounce or spam folder placement lowers your score, further harming deliverability. And as your score decreases, ESPs are more likely to flag or blocklist your domain(s) or IP.<\/p>\n\n<p class=\"wp-block-paragraph\">While this may not be a concern for internal notification systems, deliverability delays (and how you manage them) can disrupt nearly any bulk email use case. Network congestion, aggressive spam filters, and server issues can slow delivery, which is especially problematic for time-sensitive alerts. These delays can also trigger duplicate emails when systems automatically resend undelivered messages, increasing the risk of spam folder placement and further damaging your sender reputation.<\/p>\n\n<p class=\"wp-block-paragraph\">Thankfully, you can address many of these issues by enacting more control over how and when your bulk email messages are sent. Rather than blasting your messages randomly, you need a smarter approach that considers key variables. That&rsquo;s where queues come in.<\/p>\n\n<h2 class=\"wp-block-heading\">How queues can help<\/h2>\n\n<p class=\"wp-block-paragraph\">If you&rsquo;re worried about your sender reputation, queues won&rsquo;t directly or immediately amend it, but they can help improve it.<\/p>\n\n<p class=\"wp-block-paragraph\">Queues are data structures that allow you to programmatically sort and categorize your messages and then process them in succession. This enables you to coordinate and control the sending rates of your bulk email campaigns.<\/p>\n\n<p class=\"wp-block-paragraph\">For instance, you could split and group your bulk emails by mailbox provider, establish a separate queue for each group, and then set rules for how your queues are processed. This can be useful when you need to schedule emails during <a href=\"https:\/\/www.mailerlite.com\/blog\/best-time-to-send-email?form=MG0AV3\" target=\"_tabs\" rel=\"noopener noreferrer\">off-peak hours<\/a> to increase deliverability.<\/p>\n\n<p class=\"wp-block-paragraph\">Queues can also aid in load balancing since they enable you to implement short intervals or pauses between processing each group of emails. You can also temporarily store outgoing messages, giving the server time to process each load.<\/p>\n\n<p class=\"wp-block-paragraph\">Queuing systems also make handling undelivered emails more efficient. You can set up smart resend strategies to retry messages that failed due to network or server errors while skipping those with invalid addresses or full inboxes. You can also use your queues to set up a bounce list to filter out unreliable recipient addresses.<\/p>\n\n<p class=\"wp-block-paragraph\">Beyond that, queues help optimize bulk email campaigns by simplifying performance monitoring. Because they allow you to control the flow of your outgoing emails, they make it easier to spot bottlenecks, refine your strategy, and troubleshoot issues.<\/p>\n\n<h2 class=\"wp-block-heading\">Streamlining bulk email sending with queues and Mailgun<\/h2>\n\n<p class=\"wp-block-paragraph\">For this guide, let&rsquo;s imagine that you&rsquo;re building a workforce notification service for a large global corporation with staff and branches in different regions all over the world. Some messages will be company-wide, while others will be location- or department-specific.<\/p>\n\n<h3 class=\"wp-block-heading\">Select your queuing solution<\/h3>\n\n<p class=\"wp-block-paragraph\">The first thing you need to do is figure out what tools and components you&rsquo;ll need for this project. You have the following options for queue management:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.rabbitmq.com\/\" target=\"_tabs\" rel=\"noopener noreferrer\">RabbitMQ<\/a> is an open source message broker that has flexible routing and multiple protocols. Thanks to a thriving community, it features <a href=\"https:\/\/www.rabbitmq.com\/client-libraries\/devtools\" target=\"_tabs\" rel=\"noopener noreferrer\">client libraries<\/a> and developer tools for Java, .NET, Erlang, Python, PHP, JavaScript, and Go.<\/li>\n\n\n\n<li><a href=\"https:\/\/aws.amazon.com\/sqs\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Amazon SQS<\/a> is a great option if you&rsquo;re already embedded in the AWS ecosystem or want a fully managed solution. Its biggest selling points are its support for distributed queuing systems and its scalability.<\/li>\n\n\n\n<li><a href=\"https:\/\/kafka.apache.org\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Apache Kafka<\/a> is a multipurpose, open source, distributed data streaming and processing platform that can be used as a message broker. Because it was created to handle large volumes of real-time data, it offers superior throughput to most traditional queuing or message brokers. However, configuring and managing Kafka can be challenging due to its complexity.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.redpanda.com\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Redpanda<\/a> is a simplified and less resource-intensive alternative to Kafka. It&rsquo;s compatible with Kafka&rsquo;s APIs and supports many of the same implementations, including message brokering.<\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\">Since this could be a fairly large project, a managed solution with automatic scaling \u2013 like SQS \u2013 is preferable. However, if you have the experience and resources to self-manage, an open source solution can cut costs and offer more customization.<\/p>\n\n<p class=\"wp-block-paragraph\">But instead of handling email management yourself, a smarter solution is <a href=\"https:\/\/www.mailgun.com\/fr\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Sinch Mailgun<\/a>. It not only simplifies email delivery but also lets you create custom queues, giving you full control without the hassle of managing infrastructure.<\/p>\n\n<h3 class=\"wp-block-heading\">Architecture overview<\/h3>\n\n<p class=\"wp-block-paragraph\">The next few sections will show you how to programmatically create custom queues to manage your bulk email campaigns. This example uses RabbitMQ for queue creation and management and the <a href=\"https:\/\/mailgun-docs.redoc.ly\/docs\/mailgun\/sdk\/java_sdk\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Sinch Mailgun Java SDK<\/a> to send mail messages asynchronously. Because RabbitMQ and Sinch Mailgun support a wide variety of programming languages and frameworks, you can adapt this example to whatever programming language you prefer.<\/p>\n\n<p class=\"wp-block-paragraph\">Along with the <a href=\"https:\/\/documentation.mailgun.com\/docs\/mailgun\/api-reference\/\" target=\"_tabs\" rel=\"noopener noreferrer\">HTTP API<\/a> and the Java SDK, Sinch Mailgun offers language-specific software development kits for <a href=\"https:\/\/mailgun-docs.redoc.ly\/docs\/mailgun\/sdk\/go_sdk\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Go<\/a>, <a href=\"https:\/\/mailgun-docs.redoc.ly\/docs\/mailgun\/sdk\/nodejs_sdk\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Node.js<\/a>, <a href=\"https:\/\/mailgun-docs.redoc.ly\/docs\/mailgun\/sdk\/php_sdk\/\" target=\"_tabs\" rel=\"noopener noreferrer\">PHP<\/a>, and <a href=\"https:\/\/mailgun-docs.redoc.ly\/docs\/mailgun\/sdk\/ruby_sdk\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Ruby<\/a>.<\/p>\n\n<p class=\"wp-block-paragraph\">You can use the following architecture diagram (and its subsequent explanation) to better understand the queuing and bulk mailing system&rsquo;s structure and functionality:<\/p>\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-3946\" width=\"1518\" height=\"1040\" src=\"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.23C3A2__AM.png\" alt=\"Simple mailing queue system using Mailgun diagram\" srcset=\"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.23C3A2__AM.png 1518w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.23C3A2__AM-300x206.png 300w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.23C3A2__AM-768x526.png 768w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.23C3A2__AM-1024x702.png 1024w\" sizes=\"(max-width: 1518px) 100vw, 1518px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">This system uses a Sinch Mailgun API (<code>MailgunMailingListApi<\/code>) to fetch all the <a href=\"https:\/\/documentation.mailgun.com\/docs\/mailgun\/email-best-practices\/mailinglists\/?form=MG0AV3\" target=\"_tabs\" rel=\"noopener noreferrer\">mailing lists<\/a> connected to your account. Mailing lists can be created and populated programmatically from a user registration client\/application or manually using the <a href=\"https:\/\/app.mailgun.com\/mg\/sending\/mailing-lists\" target=\"_tabs\" rel=\"noopener noreferrer\">Sinch Mailgun dashboard<\/a>. Mailing lists allow you to organize and manage your email recipients in a structured manner, and they serve as your system&rsquo;s data source.<\/p>\n\n<p class=\"wp-block-paragraph\">Once the system has fetched all mailing lists, a RabbitMQ queue is created for each. The queues are populated with the email contents as well as the name and address of each recipient (member) who will receive the email.<\/p>\n\n<p class=\"wp-block-paragraph\">A separate module, containing scheduled executors for each queue, listens for new items on queues at specific intervals. If any of the executors discover new items on the queue, it will begin consuming and processing the queue. In the final step, the system&rsquo;s email processor uses <code>MailgunMessagesApi<\/code> to send the message.<\/p>\n\n<p class=\"wp-block-paragraph\">You can increase the robustness of the system by adding a queue or database to handle messages that may have failed to send and archive successful ones.<\/p>\n\n<h3 class=\"wp-block-heading\">Create your queues<\/h3>\n\n<p class=\"wp-block-paragraph\">To create a queue, you need to configure and run an instance of RabbitMQ <a href=\"https:\/\/medium.com\/@buttraheel6\/simplifying-rabbitmq-setup-with-docker-a-step-by-step-guide-9698dc9ea4ff\" target=\"_tabs\" rel=\"noopener noreferrer\">using Docker<\/a>. Once that&rsquo;s done, you can create a new Java project for queue creation. Make sure you add the following libraries to your project&rsquo;s list of dependencies:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>The <a href=\"https:\/\/mvnrepository.com\/artifact\/com.rabbitmq\/amqp-client\/5.25.0\" target=\"_tabs\" rel=\"noopener noreferrer\">RabbitMQ amqp-client<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/mvnrepository.com\/artifact\/com.mailgun\/mailgun-java\/1.1.4\" target=\"_tabs\" rel=\"noopener noreferrer\">Mailgun<\/a><\/li>\n\n\n\n<li>The <a href=\"https:\/\/mvnrepository.com\/artifact\/org.slf4j\/slf4j-api\/2.0.17\" target=\"_tabs\" rel=\"noopener noreferrer\">Simple Logging Facade for Java<\/a><\/li>\n<\/ul>\n\n<p class=\"wp-block-paragraph\">You&rsquo;ll also need to add the following imports to your main class:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                    \/\/ Mailgun importsrnimport com.mailgun.api.v3.MailgunMailingListApi;rnimport com.mailgun.client.MailgunClient;rnimport com.mailgun.model.mailing.lists.MailingListData;rnimport com.mailgun.model.mailing.lists.MailingListMember;rnrn\/\/ RabbitMQ importsrnimport com.rabbitmq.client.AMQP;rnimport com.rabbitmq.client.ConnectionFactory;rnimport com.rabbitmq.client.Connection;rnimport com.rabbitmq.client.Channel;rnrn\/\/ Java importsrnimport java.io.IOException;rnimport java.util.HashMap;rnimport java.util.Map;rnimport java.util.concurrent.TimeoutException;rn\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n<p class=\"wp-block-paragraph\">Your <code>main<\/code> method will be populated with code to initialize the Sinch Mailgun Mailing List API, initialize a connection to RabbitMQ, and create a queue for each mailing list:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                    public static void main(String[] args) throws IOException, TimeoutException{rn    \/\/ Initialize Mailing List APIrn    \/\/ Replace with your own Sinch Mailgun API keyrn    MailgunMailingListApi mailgunMailingListApi = MailgunClient.config(&quot;&lt;SINCH_API_KEY&gt;&quot;)rn        .createApi(MailgunMailingListApi.class);rnrn    \/\/ Initialize and create connection to RabbitMQ   rn    ConnectionFactory factory = new ConnectionFactory();rn    \/\/ Replace with your detailsrn    factory.setHost(&quot;&lt;HOSTNAME&gt;&quot;);                                           rn    factory.setUsername(&quot;&lt;USERNAME&gt;&quot;);rn    factory.setPassword(&quot;&lt;PASSWORD&gt;&quot;);rn    factory.setPort(&lt;PORT&gt;);rnrn    \/\/ Create queue channel - throws IOException and TimeoutExceptionrn    Connection connection = factory.newConnection();rn    Channel channel = connection.createChannel();    rnrn    \/\/ Loop through mailing listsrn    for(MailingListData mailingList : mailgunMailingListApi.getMailingList().getItems()) {rn        String queue_name = mailingList.getName();rnrn        \/\/ Create a simple queue using the mailing list name                rn        channel.queueDeclare(queue_name, false, false, false, null);rnrn        \/\/ Populate queue with mailing list member addresses and message contentrn        for(MailingListMember mailingListMember : mailgunMailingListApi.getMailingListMembers(mailingList.getAddress()).getItems()) {rn            \/\/ Create headers with email message detailsrn            Map&lt;String, Object&gt; headers = new HashMap&lt;String, Object&gt;();rn            headers.put(&quot;address&quot;, mailingListMember.getAddress());rn            headers.put(&quot;name&quot;, mailingListMember.getName());rn            headers.put(&quot;subject&quot;, &quot;Alert&quot;);          rn            \/\/ Add a row to the queue  rn            \/\/ Replace with actual email contentrn            String emailMessage = &quot;Email content&quot;;       rn            channel.basicPublish(&quot;&quot;, queue_name,rn                                 new AMQP.BasicProperties.Builder()rn                                 .headers(headers)rn                                 .build(),rn                                 emailMessage.getBytes());rnrn            \/\/ Add code to log each queued entryrn            System.out.println(&quot;Sent: &quot; + emailMessage);rn        }    rnrn    }rnrn}\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n    <div data-content-type=\"longform\"  class=\"callout text-body-color px-5 py-6 px-md-6 px-lg-7 py-md-7 longform-spacings rounded-lg bg-light\" data-theme=\"light\">\r\n\r\n        <div class=\"content-body\"> You can find the Sinch Mailgun API key under the <a href='https:\/\/app.mailgun.com\/settings\/api_security'>API Security section<\/a> of your account.<\/div>\r\n    <\/div>\r\n\n<p class=\"wp-block-paragraph\">Once the necessary connections are established, the code generates a queue for each mailing list using its name. A <code>for-each<\/code> loop fetches every member (<code>MailingListMember<\/code>) of the corresponding mailing list. Then, the code uses each member&rsquo;s details (address and name) along with the email message&rsquo;s details (subject and message contents) to create and publish a queue entry.<\/p>\n\n<p class=\"wp-block-paragraph\">At this point, you could add code to create additional queues for message\/subject types. For instance, you could create separate queues for newsletters, notifications, alerts, and other important updates. This would give you more granular control over how your messages are prioritized and sent. However, for simplicity&rsquo;s sake, you can skip this step.<\/p>\n\n<p class=\"wp-block-paragraph\">Once the code runs (successfully), you should be able to view and manage your queues from the RabbitMQ dashboard:<\/p>\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" class=\"wp-image-3949\" width=\"1906\" height=\"886\" src=\"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.34C3A2__AM.png\" alt=\"Queues and Streams screen \" srcset=\"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.34C3A2__AM.png 1906w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.34C3A2__AM-300x139.png 300w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.34C3A2__AM-768x357.png 768w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.34C3A2__AM-1024x476.png 1024w, https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/Screenshot_2025-05-21_at_9.09.34C3A2__AM-1536x714.png 1536w\" sizes=\"(max-width: 1906px) 100vw, 1906px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">Now, you need a client to consume the queues and send your messages.<\/p>\n\n<h3 class=\"wp-block-heading\">Consume your queues and send your messages<\/h3>\n\n<p class=\"wp-block-paragraph\">Just like the previous module, this module requires you to add the RabbitMQ amqp-client, SLF4J, and Mailgun libraries as dependencies. You&rsquo;ll also need to add the latest <a href=\"https:\/\/mvnrepository.com\/artifact\/io.github.openfeign\/feign-core\" target=\"_tabs\" rel=\"noopener noreferrer\">Feign Core library<\/a> and the following imports to your new module&rsquo;s main class:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                    \/\/ RabbitMQ importsrnimport com.rabbitmq.client.Channel;rnimport com.rabbitmq.client.ConnectionFactory;rnimport com.rabbitmq.client.Connection;rnimport com.rabbitmq.client.DeliverCallback;rnrn\/\/ Mailgun importsrnimport com.mailgun.api.v3.MailgunMessagesApi;rnimport com.mailgun.client.MailgunClient;rnimport com.mailgun.model.message.Message;rnimport com.mailgun.model.message.MessageResponse;rnrn\/\/ Feign Core importsrnimport feign.AsyncClient;rnimport feign.Client;rnrn\/\/ Java importsrnimport java.util.concurrent.ScheduledExecutorService;rnimport java.util.concurrent.TimeUnit;rnimport java.io.IOException;rnimport java.nio.charset.StandardCharsets;rnimport java.util.Map;rnimport java.util.concurrent.CompletableFuture;rnimport java.util.concurrent.ExecutorService;rnimport java.util.concurrent.Executors;rnimport java.util.concurrent.TimeoutException;rn\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n<p class=\"wp-block-paragraph\">Next, you need to consider how you want your queues to be processed and establish the necessary rules. For instance, if you want each queue to be processed at different hourly intervals, you&rsquo;ll need to set up and create a <code>ScheduledExecutorService<\/code>:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(3);rnrn    public void startProcessing() {rn        Runnable china_task = () -&gt; {rn            try {rn                consumeEmails(&quot;China&quot;);rn            } catch (Exception e) {rn                e.printStackTrace();rn            }rn        };rnrn        Runnable britain_task = () -&gt; {rn            try {rn                consumeEmails(&quot;Britain&quot;);rn            } catch (Exception e) {rn                e.printStackTrace();rn            }rn        };rnrn        Runnable america_task = () -&gt; {rn            try {rn                consumeEmails(&quot;America&quot;);rn            } catch (Exception e) {rn                e.printStackTrace();rn            }rn        };rnrn        \/\/ Schedule each task to run at different hourly intervalsrn        scheduler.scheduleWithFixedDelay(china_task, 11, 11, TimeUnit.HOURS);rn        scheduler.scheduleWithFixedDelay(britain_task, 13, 13, TimeUnit.HOURS); rn        scheduler.scheduleWithFixedDelay(america_task, 17, 17, TimeUnit.HOURS); rn    }rnrn    public void stopProcessing() {rn        scheduler.shutdown();rn    }\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n<p class=\"wp-block-paragraph\">Remember to add the above code to your new module&rsquo;s <code>main<\/code> class.<\/p>\n\n<p class=\"wp-block-paragraph\">Since the example application has three queues, you&rsquo;ll need to instantiate a <code>ScheduledExecutorService<\/code> object with a core thread pool size of three. You can then create a task and set a delay interval for each queue.<\/p>\n\n<p class=\"wp-block-paragraph\">In this example, each runnable task is named after a queue (mailing list), but you can name your tasks however you wish. The <code>stopProcessing<\/code> method shuts the scheduler down when you exit the application.<\/p>\n\n<p class=\"wp-block-paragraph\">Now, you can create a method to handle your queues:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                    public void consumeEmails(String queueName) throws IOException, TimeoutException {rnrn    ConnectionFactory factory = new ConnectionFactory();rn    \/\/ Replace with your detailsrn    factory.setHost(&quot;&lt;HOST&gt;&quot;);                                           rn    factory.setUsername(&quot;&lt;USERNAME&gt;&quot;);rn    factory.setPassword(&quot;&lt;PASSWORD&gt;&quot;);rn    factory.setPort(&lt;PORT&gt;);rnrn    Connection connection = factory.newConnection();rn    Channel channel = connection.createChannel();rnrn    channel.queueDeclare(queueName, false, false, false, null);rn    \/\/ Send the messagern    DeliverCallback deliverCallback = (consumerTag, delivery) -&gt; {rn        String emailMessage = new String(delivery.getBody(), StandardCharsets.UTF_8);rn        Map &lt;String, Object&gt; headers = delivery.getProperties().getHeaders();rnrn        String recipient = headers.get(&quot;address&quot;).toString();rn        String subject = headers.get(&quot;subject&quot;).toString();rn        String name = headers.get(&quot;name&quot;).toString();rn        String body = &quot;Dear &quot; + name + &quot;,\n&quot; + emailMessage;rnrn        sendEmail(recipient, subject, body);rn    };rn    channel.basicConsume(queueName, true, deliverCallback, consumerTag -&gt; { });rn}\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n<p class=\"wp-block-paragraph\">The <code>consumeEmails<\/code> method establishes a connection to your queue, parses through it, fetches the details of each entry, then passes them to <code>sendEmail<\/code>. Once the email is successfully sent, it&rsquo;s labeled as consumed on the queue&rsquo;s registry.<\/p>\n\n<p class=\"wp-block-paragraph\">Let&rsquo;s take a closer look at the <code>sendEmail<\/code> method:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                    public void sendEmail(String recipient, String subject, String body) {rn    \/\/ Create async clientrn    ExecutorService executor = Executors.newFixedThreadPool(1);rn    AsyncClient.Default&lt;Object&gt; asyncClient = new AsyncClient.Default&lt;&gt;(rn        new Client.Default(null, null), executor);rnrn    MailgunMessagesApi mailgunMessagesApi = MailgunClient.config(&quot;&lt;SINCH_MAILGUN_API_KEY&gt;&quot;)rn        .client(asyncClient)rn        .createApi(MailgunMessagesApi.class);rnrn    Message message = Message.builder()rn        .from(&quot;&lt;REPLY_INBOX&gt;&quot;)rn        .to(recipient)rn        .subject(subject)rn        .text(body)rn        .build();rnrn    CompletableFuture&lt;MessageResponse&gt; messageResponse = mailgunMessagesApi.sendMessageAsync(&quot;&lt;SINCH_MAILGUN_DOMAIN&gt;&quot;, message);rn    \/\/ Log message responsern    System.out.println(messageResponse);rnrn}\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n<p class=\"wp-block-paragraph\">When you use the standard <a href=\"https:\/\/github.com\/mailgun\/mailgun-java?tab=readme-ov-file#send-email\" target=\"_tabs\" rel=\"noopener noreferrer\">send method<\/a> (<code>mailgunMessagesApi.sendMessage(\"\", message)<\/code>), Mailgun places your message in a queue for processing. You can bypass the queue by sending the message asynchronously. This requires you to create an <code>AsyncClient<\/code> to bind to the Mailgun Messages API.<\/p>\n\n<p class=\"wp-block-paragraph\">Once that&rsquo;s done, the code builds your message with the details from the RabbitMQ queue and then sends it using the Mailgun Messages API.<\/p>\n\n<p class=\"wp-block-paragraph\">To run your application, you need to add a call to the <code>startProcessing() <\/code>method in your <code>main<\/code> method and some code to handle application termination:<\/p>\n    <div data-content-type=\"longform\" class=\"code-snippet longform-spacings rounded-lg overflow-hidden shadow \" data-count=\"1\">\r\n        <ul class=\"nav nav-buttons code-snippet__tabs longform-except position-relative d-flex gap-2 flex-wrap p-3\" role=\"tablist\">\r\n\r\n                            \r\n                    \r\n                        <li class=\"nav-item\" role=\"presentation\">\r\n                            <button class=\"nav-link active\" data-bs-toggle=\"tab\" data-bs-target=\"#code_0\" type=\"button\" role=\"tab\" aria-controls=\"code_0\" aria-selected=\"true\">\r\n                                PHP                            <\/button>\r\n                        <\/li>\r\n\r\n                    \r\n                            \r\n        <\/ul>\r\n        <div class=\"code-snippet__tab-content tab-content\">\r\n\r\n                            \r\n                    <div class=\"tab-pane show active\" id=\"code_0\" role=\"tabpanel\" aria-labelledby=\"code_0\">\r\n                        <div class=\"code-snippet__code-wrapper\">\r\n                            <div class=\"nav nav-buttons code-snippet__copy-wrapper\">\r\n                                <button type=\"button\" class=\"nav-link code-snippet__copy\" data-clipboard-target=\"#code_0_content\" data-clipboard-label=\"Copier dans le presse-papiers\" data-clipboard-success-label=\"Copi\u00e9\u00a0!\" data-clipboard-error-label=\"Impossible de copier\" data-tooltip=\"Copier dans le presse-papiers\" data-tooltip-placement=\"left\" role=\"tooltip\" aria-label=\"Copier dans le presse-papiers\">\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--default\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/file-stack.svg\"><\/svg>\r\n                                    <svg class=\"code-snippet__copy-icon code-snippet__copy-icon--success\" width=\"24\" height=\"24\" aria-hidden=\"true\" data-url=\"https:\/\/www.mailgun.com\/wp-content\/plugins\/sinch-core\/assets\/icons\/sinch\/badge-check.svg\"><\/svg>\r\n                                <\/button>\r\n                            <\/div>\r\n                            <pre class=\"w-100 h-100 m-0 line-numbers language-PHP\">\r\n                                <code id=\"code_0_content\" class=\"language-PHP\">\r\n\r\n                                        public static void main(String[] args) {                                   rn        \/\/ Your main class rn        SinchRabbitMQConsumer processor = new SinchRabbitMQConsumer();                              rn        processor.startProcessing();rnrn        \/\/ Add a shutdown hook to stop processing when the application is terminatedrn        Runtime.getRuntime().addShutdownHook(new Thread(processor::stopProcessing));rn    }\r\n                                <\/code>\r\n                            <\/pre>\r\n                        <\/div>\r\n                    <\/div>\r\n                                    <\/div>\r\n    <\/div>\r\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n<p class=\"wp-block-paragraph\">In this article, you learned how queues can help manage the flow of your mass email campaigns and give you granular control over how your bulk emails are sent. When implemented through a competent queue management system, queues help you mitigate issues like rate limiting, throttling, and network congestion.<\/p>\n\n<p class=\"wp-block-paragraph\">Regardless of how you implement and manage your queues, a reliable sending partner like <a href=\"https:\/\/sinch.com\/products\/mailgun-send\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Mailgun<\/a> can help.a<\/p>\n\n<p class=\"wp-block-paragraph\">As an API-first platform, Mailgun provides you with a litany of tools to not just send but programmatically scale, monitor, and track your campaigns. Check out the official <a href=\"https:\/\/documentation.mailgun.com\/docs\/mailgun\/user-manual\/get-started\/\" target=\"_tabs\" rel=\"noopener noreferrer\">Send API documentation<\/a> and be sure to subscribe to our newsletter for more tutorials like this.<\/p>\n\r\n    <aside data-content-type=\"longform\"  class=\"banner-block longform-spacings rounded-lg shadow-lg px-5 py-6 px-md-6 py-md-7 p-lg-7 bg-light\" data-theme=\"dark\" aria-labelledby=\"banner-block-block_b867a1d728d476440f5625aebc36424b\">\r\n                    <p class=\"text-uppercase section-caption text-body-color\">\r\n                Sign Up            <\/p>\r\n                            <p class=\"h4 text-accent fw-bold\" id=\"banner-block-block_b867a1d728d476440f5625aebc36424b\">\r\n                It&rsquo;s easy to get started. And it&rsquo;s free.            <\/p>\r\n                            <div class=\"mb-0 text-body-color\">\r\n                                    <div class=\"content-body mb-0 text-body-color\">See what you can accomplish with the world\u2019s best email delivery platform.<\/div>\r\n                            <\/div>\r\n        \r\n        <div class=\"text-start mt-5\"><a href=\"https:\/\/signup.mailgun.com\/new\/signup\"  class=\"btn btn-secondary\" >Get started<\/a><\/div>\r\n    <\/aside>\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>L&rsquo;envoi d&#8217;emails en masse n&rsquo;est pas aussi simple que de cliquer sur \u00ab\u00a0envoyer\u00a0\u00bb. Ce guide explique comment la gestion personnalis\u00e9e des files d&rsquo;attente avec l&rsquo;API de Mailgun vous aide \u00e0 contr\u00f4ler le calendrier de vos campagnes, maintenir votre d\u00e9livrabilit\u00e9 et \u00e9viter les pi\u00e8ges qui risquent de nuire \u00e0 votre r\u00e9putation d&rsquo;exp\u00e9diteur.<\/p>\n","protected":false},"author":6,"featured_media":3952,"menu_order":0,"template":"","meta":{"_acf_changed":false,"footnotes":""},"blog_category":[19],"class_list":["post-20327","blog","type-blog","status-publish","has-post-thumbnail","hentry","blog_category-dev-life"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Comment optimiser l&#039;envoi d&#039;emails en masse avec l&#039;API de Mailgun - Transactional Email API Service For Developers | Mailgun<\/title>\n<meta name=\"description\" content=\"D\u00e9couvrez comment g\u00e9rer l&#039;envoi d&#039;emails en masse \u00e0 l&#039;aide de files d&#039;attente personnalis\u00e9es avec l&#039;API de Mailgun pour \u00e9viter les limites de volume, am\u00e9liorer votre d\u00e9livrabilit\u00e9 et optimiser vos performances.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Comment optimiser l&#039;envoi d&#039;emails en masse avec l&#039;API de Mailgun - Transactional Email API Service For Developers | Mailgun\" \/>\n<meta property=\"og:description\" content=\"D\u00e9couvrez comment g\u00e9rer l&#039;envoi d&#039;emails en masse \u00e0 l&#039;aide de files d&#039;attente personnalis\u00e9es avec l&#039;API de Mailgun pour \u00e9viter les limites de volume, am\u00e9liorer votre d\u00e9livrabilit\u00e9 et optimiser vos performances.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/\" \/>\n<meta property=\"og:site_name\" content=\"Transactional Email API Service For Developers | Mailgun\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-15T10:04:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Dev-Life.png\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"448\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/\",\"name\":\"Comment optimiser l'envoi d'emails en masse avec l'API de Mailgun - Transactional Email API Service For Developers | Mailgun\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/MG-Blog-Dev-Life.png\",\"datePublished\":\"2025-08-29T00:00:00+00:00\",\"dateModified\":\"2026-09-15T10:04:46+00:00\",\"description\":\"D\u00e9couvrez comment g\u00e9rer l'envoi d'emails en masse \u00e0 l'aide de files d'attente personnalis\u00e9es avec l'API de Mailgun pour \u00e9viter les limites de volume, am\u00e9liorer votre d\u00e9livrabilit\u00e9 et optimiser vos performances.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/MG-Blog-Dev-Life.png\",\"contentUrl\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/07\\\/MG-Blog-Dev-Life.png\",\"width\":720,\"height\":448},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/dev-life\\\/envoi-emails-masse-gestion-files-attente\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Optimiser l\u2019envoi d\u2019emails en masse par la gestion personnalis\u00e9e des files d\u2019attente avec l\u2019API de Mailgun\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/#website\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/\",\"name\":\"Transactional Email API Service For Developers | Mailgun\",\"description\":\"Des API d\u2019emails transactionnels puissantes qui vous permettent d'envoyer, de recevoir et de suivre des emails, con\u00e7ues pour les d\u00e9veloppeurs. En savoir plus d\u00e8s aujourd'hui !\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/#organization\",\"name\":\"Transactional Email API Service For Developers | Mailgun\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-android-chrome-512x512-1.png\",\"contentUrl\":\"https:\\\/\\\/www.mailgun.com\\\/wp-content\\\/uploads\\\/2025\\\/06\\\/cropped-android-chrome-512x512-1.png\",\"width\":512,\"height\":512,\"caption\":\"Transactional Email API Service For Developers | Mailgun\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mailgun.com\\\/fr\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Comment optimiser l'envoi d'emails en masse avec l'API de Mailgun - Transactional Email API Service For Developers | Mailgun","description":"D\u00e9couvrez comment g\u00e9rer l'envoi d'emails en masse \u00e0 l'aide de files d'attente personnalis\u00e9es avec l'API de Mailgun pour \u00e9viter les limites de volume, am\u00e9liorer votre d\u00e9livrabilit\u00e9 et optimiser vos performances.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/","og_locale":"fr_FR","og_type":"article","og_title":"Comment optimiser l'envoi d'emails en masse avec l'API de Mailgun - Transactional Email API Service For Developers | Mailgun","og_description":"D\u00e9couvrez comment g\u00e9rer l'envoi d'emails en masse \u00e0 l'aide de files d'attente personnalis\u00e9es avec l'API de Mailgun pour \u00e9viter les limites de volume, am\u00e9liorer votre d\u00e9livrabilit\u00e9 et optimiser vos performances.","og_url":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/","og_site_name":"Transactional Email API Service For Developers | Mailgun","article_modified_time":"2026-09-15T10:04:46+00:00","og_image":[{"width":720,"height":448,"url":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Dev-Life.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/","url":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/","name":"Comment optimiser l'envoi d'emails en masse avec l'API de Mailgun - Transactional Email API Service For Developers | Mailgun","isPartOf":{"@id":"https:\/\/www.mailgun.com\/fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/#primaryimage"},"image":{"@id":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Dev-Life.png","datePublished":"2025-08-29T00:00:00+00:00","dateModified":"2026-09-15T10:04:46+00:00","description":"D\u00e9couvrez comment g\u00e9rer l'envoi d'emails en masse \u00e0 l'aide de files d'attente personnalis\u00e9es avec l'API de Mailgun pour \u00e9viter les limites de volume, am\u00e9liorer votre d\u00e9livrabilit\u00e9 et optimiser vos performances.","breadcrumb":{"@id":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/#primaryimage","url":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Dev-Life.png","contentUrl":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/07\/MG-Blog-Dev-Life.png","width":720,"height":448},{"@type":"BreadcrumbList","@id":"https:\/\/www.mailgun.com\/fr\/blog\/dev-life\/envoi-emails-masse-gestion-files-attente\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mailgun.com\/fr\/"},{"@type":"ListItem","position":2,"name":"Blog","item":"https:\/\/www.mailgun.com\/fr\/blog\/"},{"@type":"ListItem","position":3,"name":"Optimiser l\u2019envoi d\u2019emails en masse par la gestion personnalis\u00e9e des files d\u2019attente avec l\u2019API de Mailgun"}]},{"@type":"WebSite","@id":"https:\/\/www.mailgun.com\/fr\/#website","url":"https:\/\/www.mailgun.com\/fr\/","name":"Transactional Email API Service For Developers | Mailgun","description":"Des API d\u2019emails transactionnels puissantes qui vous permettent d'envoyer, de recevoir et de suivre des emails, con\u00e7ues pour les d\u00e9veloppeurs. En savoir plus d\u00e8s aujourd'hui !","publisher":{"@id":"https:\/\/www.mailgun.com\/fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mailgun.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/www.mailgun.com\/fr\/#organization","name":"Transactional Email API Service For Developers | Mailgun","url":"https:\/\/www.mailgun.com\/fr\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.mailgun.com\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/06\/cropped-android-chrome-512x512-1.png","contentUrl":"https:\/\/www.mailgun.com\/wp-content\/uploads\/2025\/06\/cropped-android-chrome-512x512-1.png","width":512,"height":512,"caption":"Transactional Email API Service For Developers | Mailgun"},"image":{"@id":"https:\/\/www.mailgun.com\/fr\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/blog\/20327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/users\/6"}],"version-history":[{"count":2,"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/blog\/20327\/revisions"}],"predecessor-version":[{"id":21112,"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/blog\/20327\/revisions\/21112"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/media\/3952"}],"wp:attachment":[{"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/media?parent=20327"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.mailgun.com\/fr\/wp-json\/wp\/v2\/blog_category?post=20327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}