As we saw in part 1, I was experiencing timeouts on scripts that sent a large number of legitimate messages out from php mailer. This appeared to be related to the web hosting company throttling the email rate. To still be able to send these messages out a setup was required that would allow messages to be released in smaller batches. Part 1 saw the setup of this script. Now we cover the script that will be used to send the mail out, and how to produce a simple report that shows messages in the queue.

Firstly we will cover the mailing script. This I called mailer.php and is called every 10 minutes by a cron timer.

So with that running correctly, every 10 minutes 50 emails should be sent out, and the database updated.

Now it would be nice to be able to see what messages are waiting. The webpage below is written in HTML and PHP and pulls the queued messages from the database and displays them in a simple table.

That completes this series. The first part was used to redirect email into the holding database table, then this part extracted a batch of emails and sent them out using a cron job every 10 minutes.