How can I send a queue of emails from multiple threads?

Mailing letters.
Did turn in the form of a table in MySql. The table has fields: id and status.
At status can be following values: 'awaits','sending','sended','error','delivered','opened','clicked'.

How to make a mailing from the queue, so she can run in multiple threads?

While that came up with this solution:
Cron, or something else, most often triggers a PHP script which makes a request:
SELECT * FROM mail WHERE status='awaits' ORDER BY id LIMIT 10
then he takes from the result of the min and max id, and makes
UPDATE mail SET status='sending' WHERE id >= 5 AND id <= 14

Therefore, a thread will mark a batch of emails to another thread it did not take. These 2 queries inside transactions, during the period between these data is not taken from the other thread.
Then these 10 letters are sent by their status in the database is changed to 'sended' the flow ends.
If you send out will have many, instead of the crown use that can run simultaneously on multiple threads, not a maximum of 1 times per minute.

If you offer rabbitMQ, explain what it is and what the essence of his work.
July 9th 19 at 13:58
1 answer
July 9th 19 at 14:00
First
SET @id := 0;
UPDATE `mail` 
 SET `status` = `sending` 
 WHERE (@id := `id`) AND `status` = 'awaits' 
 ORDER BY `id`
 LIMIT 1;

Then
SELECT * FROM `mail` WHERE `id` = @id;
The script can be run from Krona once every minute, but make a loop in it. While there are tasks to send the script must not fail. Then the number of scripts will increase every minute until everything is sent.
>can't
Then have the PHP max_execution_time to increase or check it at run time? - Jules77 commented on July 9th 19 at 14:03
: When run from console max_execution_time by default is not considered. - Kenyatta commented on July 9th 19 at 14:06

Find more questions by tags multithreadingMySQLMessage queues