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

jamescastro's avatar

Sending Bulk Email with AWS SES

My current setup is as follows:

I have a list of clients to send bulk email to. In my software I have an option to send immediately or schedule a time of when it should be sent. I save the email details in my database with a send time and date and then have setup a schedule in the console kernel.php to check that table and if there are emails due to be sent then they will be sent.

Firstly I am confirming their is no need to queue this to SQS as basically my setup is essentially queuing it (Unless there are benefits I am not aware of)

Now I can see that there are two options:

  1. I loop through the students and send individually to SES.
  2. Send through AWS SDK creating a template and sending the emails in one go.

With option 1, I have a limit of 14 emails per second with SES so I have come up with this.

        $i=0;
                foreach($clients as $client){

                    // send email code

                    if(($i++ % 10) == 0) {
                        sleep(1);
                    }
                }

I believe this will only send 10 per second.

With option 2 I have a limit of 50 email addresses with each call (I think thats the limit) so need to send in batches of 50 which would be fairly straightforward.

So my question is which is better and if I use option 1 is my code correct or is there a better way of writing it?

Or am I doing it all wrong and there is a better way!!

0 likes
5 replies
jamescastro's avatar

I have found that already and yeah it shows me how to implement the template option. But I am really interested to know what the best option is and reasons why if I am sending a few thousand emails.

martinbean's avatar

@jamescastro Don’t. SES isn’t for sending bulk emails. Use a service that is, such as MailChimp or Campaign Monitor.

jamescastro's avatar

@martinbean Amazon would completely disagree with you there! So why isn't it a good solution in your opinion?

I am following all the best practices with double opt ins, I have everything built in to deal with bounces and spam complaints. Tracking is really good with AWS so I can provide stats to my customers and the best thing it is seamlessly built into my software so my customers don't have to manage external email lists.

jamescastro's avatar
jamescastro
OP
Best Answer
Level 9

For anyone else that wants an answer to this the solution is as follows:

If you are sending emails and dealing with any dynamic data yourself just use option 1 and loop over each email address and send to the SES API individually setting a delay in the script on every send. The following should send 10 every second.

foreach($clients as $client) {

    // send email code

    usleep(100000);
 
}

If you want to personalise the recipient name in the email body then use the template option and send with a maximum of 50 addresses at a time as that is the limit with each API call.

1 like

Please or to participate in this conversation.