MervCodes

Tech Reviews From A Programmer

Magento 1.9 Fix for Sending Double Emails

1 min read

Fix for Magento 1.9 sending double order confirmation emails. This is a known bug that has been affecting many Magento 1.9 installations, frustrating both store owners and customers who receive duplicate emails for every order.

The Cause

The issue is caused by duplicate entries in the core_email_queue table. When an order is placed, Magento sometimes creates two queue entries for the same email, resulting in the customer receiving the same order confirmation twice.

The Database Fix

Run this SQL query on your Magento database to identify duplicates:

SELECT entity_id, event_type, COUNT(*) as cnt
FROM core_email_queue
GROUP BY entity_id, event_type
HAVING cnt > 1;

To prevent future duplicates, you can add a cron job that cleans up the email queue before it gets processed:

DELETE t1 FROM core_email_queue t1
INNER JOIN core_email_queue t2
WHERE t1.message_id > t2.message_id
AND t1.entity_id = t2.entity_id
AND t1.event_type = t2.event_type;

The Code Fix

Alternatively, check your app/code/core/Mage/Core/Model/Email/Queue.php file. In the send() method, ensure that emails are being marked as sent correctly. Some custom modules or patches may interfere with this process.

If you're using third-party email extensions (like SMTP Pro or similar), check if they have a known conflict with Magento 1.9's email queue. Disabling the extension temporarily can help you confirm whether it's the source of the duplicate emails.