Is your Magento site sending order emails to more than one customer?
There maybe a missing foreign key constraint on the core_email_queue_recipeints table, so when the cron job clears the core_email_queue table the recipients are left, and the truncation resets the primary key to 1, causing possible collisions of past customer email addresses with new orders.
To fix it, run this sql in your phpMyAdmin account. If you prefixed your table names don’t forget to add the prefix to the table names below.
DELETE FROM core_email_queue_recipients WHERE message_id NOT IN (SELECT message_id FROM core_email_queue); DELETE FROM core_email_queue_recipients WHERE recipient_id < (SELECT recipient_id FROM (SELECT recipient_id FROM core_email_queue_recipients ORDER BY message_id ASC, recipient_id DESC LIMIT 1) AS r); ALTER TABLE core_email_queue_recipients ADD FOREIGN KEY(message_id) REFERENCES core_email_queue(message_id) ON DELETE 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, and no duplicated messages to wrong recipients will be sent in the future.
Comments are closed.