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, firstname.lastname@example.org; Example name A; 0 -- Customer confirmation 59; 1, email@example.com; ; 2 -- Blind copy of e-mail to our service 60; 2, firstname.lastname@example.org; 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.
core_email_queue_recipientsadded 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_recipientsat same time as ´core_email_queue´ ??
Mage_Core_Model_Resource_Email_Queue::removeSentMessagesmethod 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.
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.