Hello. I checked your code and I think I know where is a problem.
Look at the function alo_em_get_recipients_in_queue. It creates
a list of emails to send one batch of newsletter. The SQL inside is
something like this:
SELECT<br />
r.*, s.lang, s.unikey, s.name, u.ID as user_id, s.ID AS subscriber<br />
FROM<br />
wp_easymail_recipients AS r<br />
LEFT JOIN wp_easymail_subscribers AS s ON r.email = s.email<br />
LEFT JOIN wp_users AS u ON r.email = u.user_email<br />
INNER JOIN wp_postmeta AS pm ON pm.post_id = r.newsletter<br />
INNER JOIN wp_posts AS p ON p.ID = r.newsletter </p>
<p>WHERE<br />
pm.meta_key = '_easymail_status' AND pm.meta_value = 'sendable' AND r.result = 0 AND p.post_status = 'publish' AND newsletter = 1306<br />
ORDER BY r.ID ASC LIMIT 100
There is a lot of joins here. The problem is that there is no index on wp_users.user_email so the joins
can't be optimised by database. I have 6000 records in wp_easymail_recipients, 6000 in wp_easymail_subscribers and 15000 in wp_users. This select takes for me 2,5 minutes
Then for every newsletter email that you send you run alo_em_get_recipients_in_queue
with the same joins. When the batch is 100 it takes 250 minutes to run this selects.
So wp_cron runst every 10 minutes a send batch that takes 250 minutes. This is why
it was not working at all and why it killed my database.
If you fine tune this SQL the script will work probably 100 times faster. The major problem
is removing the join with wp_users. You use it only to take wp_users.ID. This is the variable
that never change so you can copy it to wp_easymail_subscribers.