After upgrading to 1.9.1 (from 1.7.0) I experience a lot of challenges with the Cron E-mail - and I am stuck about how to solve it...

E-MAIL QUEUE not working?

When customer or Admin added an order, e-mail confirmation was sent out to customer, with bcc to our admin e-mail. BUT it also included an other, older customer! If new order was order numer 100000500, then it also included the e-mail from order 100000495. In SQL-database I could see the reason why: After cron have sent e-mail confirmation of new order, both message and e-mail recipients were still (stuck?) in the Database. Both table: core_email_queue and Table: core_email_gueue_recipients still had both messages and e-mailadresses for sent messages.

After a while, maybe when Cron job decide to delete old messages, the message_id started at 1 once more. What happend was that old recipients and new recipients with id=1 all got the e-mail order confirmation for the new order.

It looks like cron job not delete the finished messages in table: core_email_queue but does not delete any recipient´s in table: core_email_queue_recipients.

I could solve this by deleting the rows in both tables. I haven´t found anyone experiencing same problem, any reason why it is like this, nor how to solve it correctly.

I am not totally sure, but it looks like it worked well for a few orders, after deleting the old message_id´s. We dont have many orders, so I cant confirm it 100%. Database data from table: core_email_queue_recipients:

recipient_id; message_id; recipient_email; recipient_name; email_type
58; 1, [email protected]; Example name A; 0  -- Customer confirmation
59; 1, [email protected]; ; 2  -- Blind copy of e-mail to our service
60; 2, [email protected]; Example name C; 0

Now the core_email_queue have first row with message_id 5. Previous messages with message_id 1 to 4 is not here anymore, looks like deleted by Cron job?

Is there anyone with any clues? As I am not a Magento Certified programming Professional, I appreciate any help or advices on this.

  • 1
    Today it happend again. Looks like Magento every week or something deleting (emptying) the DB table ´core_email_queue´, but not the table ´core_email_queue_recipients´. So new order got core_email_queue_recipients added with message_id = 1. The problem is only that message_id "1" already exist, with an older order. So new order confirmation was sent to both the new order e-mail and a previous ordering customer a week ago. ... Anyone have idea about how to empty the rows in table core_email_queue_recipients at same time as ´core_email_queue´ ??
    – Atian
    Commented Jan 15, 2015 at 14:47
  • The same for me. Magento queue system is buggy. Read this for the some details. Commented Mar 10, 2015 at 15:48
  • Thanks @sergii-matrunchyk . I have read that one, but I could not solve my problems. Have you solved this?
    – Atian
    Commented Mar 11, 2015 at 12:42
  • Yes, I've created a module which disables Magento Queues since I don't have a lot customers. But also I found a simple one-line workaround. Look at Mage_Core_Model_Resource_Email_Queue::removeSentMessages method and you'll see that Magento clears only 'email_queue' table. But not email_recipients! You have to add an extra delete clause to delete all recipients of already processed emails. Please note that you should add this line before deleting email_queue's rows. Sorry for my late reply. Commented Apr 6, 2015 at 15:49
  • @sergii-matrunchyk : Thanks once more for your good effort to help me. I haven't had much time to work with this, but I tried yesterday again to solve this by looking into the Mage_Core_Model_Resource_Email_Queue. Yes, it is like you say, no delete of the email_recipients. I tried to use a line like $this->_getWriteAdapter()->delete($this->getTable(), ''); return $this; but without desired results. If you have some more detailed "how to do this", I would appreciate your kind help, as I am no Magento-Expert.
    – Atian
    Commented Jun 16, 2015 at 4:00

2 Answers 2


I had the same problem and wrote a small module. It deletes the recipients whenever the cronjob runs:

Magento order confirmation is sent to all customers

  • I found that @simonthesorcerer have made a code that looks like solving this problem (or similar case), but I can not get this to work. I am not sure if that could be because of the Queue.php file using reference to array("ceqr") and ceqr.message_id = ceq.message_id . Maybe the cegr and ceg references is the reason why it doesnt work for me? I can not understand why it is used this cegr and ceg ? I dont have these anywhere within my database. Is that references to database name? Thanks for any advices - as I still haven´t solved my problems...
    – Atian
    Commented Aug 5, 2015 at 11:04
  • My module extends the cron task that empties the core_email_queue table. You have to run this task at least once before you can see the effect. I updated the linked answer. Commented Aug 5, 2015 at 12:19
  • Thanks for your comment @simonthesorcerer! I have flushed all cache, and then pushed the cron-job to run. Now I only got error message: Fatal error: Call to a member function removeSentMessages() on a non-object in /home/pandapqc/public_html/magshop/includes/src/Mage_Core_Model_Email_Queue.php on line 268. Line 268 refers to: $this->_getResource()->removeSentMessages(); I also checked location and filenames of the three files, and it looks to be correct. (But I am not an expert!) BTW: I am running version
    – Atian
    Commented Aug 5, 2015 at 15:07

I've post a fix for this issue that uses a foreign key constraint on the core_email_queue_recipients table to delete Recipients records on cascade.

By using this new foreign key, no orphan records will be left on the core_email_queue_recipients table when cleaning the core_email_queue table, so no duplicated messages will be further sent to wrong recipients.

You can find the detailed solution on this post: https://magento.stackexchange.com/a/87299/23057

Not the answer you're looking for? Browse other questions tagged or ask your own question.