I am facing issue with new order emails. Magento send new order emails two times for every order.

I am not getting what is issue there.


create custom plugin to check if the email has been already sent or not and only sent an email if its not sent before

create module.xml file

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <module name="rahul_Sendorderplugin" setup_version="1.0.0"/>



in di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <preference for="Magento\Sales\Model\Order\Email\Sender\OrderSender" type="rahul\Sendorderplugin\Model\Order\Email\Sender\OrderSender"></preference>


namespace rahul\Sendorderplugin\Model\Order\Email\Sender

use Magento\Sales\Model\Order;

class OrderSender extends \Magento\Sales\Model\Order\Email\Sender\OrderSender

    public function send(Order $order, $forceSyncMode = false)

        if (!$this->globalConfig->getValue('sales_email/general/async_sending') || $forceSyncMode) {

//$order->getEmailSent() will check if the email has been sent for order or not

            if ($this->checkAndSend($order) && !$order->getEmailSent()) {
                $this->orderResource->saveAttribute($order, ['send_email', 'email_sent']);
                return true;
        } else {
            $this->orderResource->saveAttribute($order, 'email_sent');

        $this->orderResource->saveAttribute($order, 'send_email');

        return false;

Hope this will help you and let me know if you got any issues. I will be happy to help. This is the directory structure ->

enter image description here

  • tried this but Not working :( – Magecode Dec 31 '18 at 12:57
  • sorry to hear that ,just wanted to confirm you must have enabled the module and also executed setup:di:compile command and cleaned cache. I was also facing the same issue and solved out using the same. – Rahul Makwana Dec 31 '18 at 13:00
  • I have checked all things – Magecode Dec 31 '18 at 13:05
  • not sure than :( – Rahul Makwana Dec 31 '18 at 13:07
  • you should have the directory structure like the image I have added in the answer for your new extension. – Rahul Makwana Dec 31 '18 at 14:15

I have debugged it and found solution after lots of debugging.

Issue was occurred due to Paytm payment module. It was also overriding code to send Emails.

I have disabled Paytm module and now issue resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.