Magento 1.9 Fix for Sending Double Emails or Sending Email to Wrong Recipients

by | 2 Jul 2017 | Database, Magento, MySQL, Open Source, PHP, PhpMyAdmin, Technology | 0 comments

As we know, Magento uses a cron job system to send out email from core_email_queue table. There is an additional table called core_email_queue_recipients, which as the name states, will store all recipients for emails there. But these records do not get removed at times and that is usually why you will get the issue of Magento sending double emails or sending email to wrong recipients.

Follow the following steps to have this issue fixed.

1. Clean up core_email_queue_recipients table

Executing the two SQL statements below will remove any orphan email recipient records so that Magento will not send double emails or send email to wrong receipents.

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);

2. Alter core_email_queue_recipients

Altering core_email_queue_recipients table to attach a foreign key to every recipient record so that it will get deleted when an email is done sending.

ALTER TABLE core_email_queue_recipients ADD FOREIGN KEY(message_id) REFERENCES core_email_queue(message_id) ON DELETE CASCADE;

 

You are welcome! 🙂

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Posts

AppleiOSMobile PhonesObjective-CProgrammingSwiftTechnology
How to install Cocoapods for Objective-C/Swift development on Mac OS?

How to install Cocoapods for Objective-C/Swift development on Mac OS?

Steps to install Cocoapods Cocoapods is used in Xcode IDE for development from iOS apps using Objective-C/Swift. Cocoapods helps developers add external libraries to their iOS project easily. The following tutorial guides you on the steps to install Cocoapods on...

AndroidAndroidAppleiOSJavaMobile PhonesObjective-CProgramming
iPhone Camera
Complete overview of the mobile app development process (Infographic)

Complete overview of the mobile app development process (Infographic)

Clients always have the misperception that developing a mobile app is as easy as developing a mobile application would be a walk in a park without much effort involved. The following infographic pretty much sums up the total cost and effort for mobile app...