aschroder / Magento-SMTP-Pro-Email-Extension

Full SMTP and Gmail/Google Apps Email support for Magento
aschroder.com
335 stars 207 forks source link

Duplicate email sent for order emails #152

Open snowleo208 opened 8 years ago

snowleo208 commented 8 years ago

Hello I just installed and used this extensions with SendGrid, and when customers place orders, it send 2~5 times of the same order email. How can I solve this?

My magento version is 1.9.2.2. I have set the email with BCC email to my another email address and had set whitelabel in my SendGrid account already.

arion-p commented 8 years ago

I am having the same issue. Magento version is 1.9.2.4

arion-p commented 8 years ago

I had queuing enabled. I noticed that the same set of emails sent on one cron invocation was subsequently sent again on the very next invocation. I suspect that for some reason the whole batch is wrapped in a single transaction and that transaction fails and gets rolled back (but the emails have already been sent).

I will switch to non-queued mail delivery to confirm and will report back in a few days.

Edit: I just found a set of emails that was duplicated in the same cron invocation, so my assumption is probably wrong.

Krapulat commented 8 years ago

I have the same issue.

Any solution to this?

madhifallah commented 8 years ago

try to disable queue, reapply email notif settings, add a pause between emails, reduce number of emails processed at one time.

arion-p commented 8 years ago

Disabling the queue does resolve the issue but this is suboptimal - emails should be sent on the background.

Your suggestions would make me think that the real issue is that two instances of the dequeuing task may run at the same time (i.e. first instance does not finish before cron starts the next instance). Either the second instance should quit immediately or there should be proper locking between them to ensure each email is processed by only one instance. However my observation that one email was sent twice in the same cron invocation doesn't fit with that scenario.

Krapulat commented 8 years ago

@arion-p @madhifallah If it helps, in my system the e-mail is sent twice only with 1 payment method (credit card). And the first e-mail is sent to the Magento admin. The second one is sent to the customer and to the magento admin (in the same e-mail, without cco).

shenmusam commented 6 years ago

I have sample problem,like image what should I do??

santerref commented 5 years ago

Here is a patch I have used to remove the duplicates :

@@ -76,6 +76,7 @@ class Aschroder_SMTPPro_Model_Email_Template extends Mage_Core_Model_Email_Templ

             /** @var $emailQueue Mage_Core_Model_Email_Queue */
             $emailQueue = $this->getQueue();
+            $emailQueue->clearRecipients();
             $emailQueue->setMessageBody($text);
             $emailQueue->setMessageParameters(array(
                 'subject'           => $subject,
rabraga commented 4 years ago

Hello, I tried to include the line $ emailQueue-> clearRecipients (); but continues to send duplicate email. Is this a Magento or plugin bug?