Magento – The e-mail queue not working – old recipients not deleted after receiving e-mails

ce-1.9.1.0cronemail

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, a@b.com; Example name A; 0  -- Customer confirmation
59; 1, b@a.com; ; 2  -- Blind copy of e-mail to our service
60; 2, c@c.com; 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.

Best Answer

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

Related Topic