3

Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Disabled

Where should I look and which module or modal to send the same email programmatically?

Update

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\Order')->load($orderId);

$emailSender = $objectManager->create('\Magento\Sales\Model\Order\Email\Sender\OrderSender');
$emailSender->send($order);

If I Admin -> Stores -> Configuration -> Sales -> Sales Email -> Order -> Disabled the above code doesn't trigger the email. Or if I enable, it send 2 email. I don't want the email that magento trigger for order confirmation. I want to do it.

  • Hello @iamkdev, it will send admin too? – chirag May 30 '18 at 14:00
4

Look at Magento\Sales\Model\Order\Email\Sender\OrderSender. This is where you'll find the method to send the order confirmation for a given order.

| improve this answer | |
0

Simply you can use below code to send order email

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();        
$order = $objectManager->create('\Magento\Sales\Model\Order')->load($orderId);
$order->setCanSendNewEmailFlag(true);
$order->save();
$session->setForceOrderMailSentOnSuccess(true);
$emailSender = $objectManager->create('\Magento\Sales\Model\Order\Email\Sender\OrderSender');
$emailSender->send($order);

You should not use the ObjectManager directly!

| improve this answer | |
-3

I created an around plugin for the send function OrderSender and check my custom condition. Now it works for me.

| improve this answer | |
  • 1
    Can you please share your plugin code? we have same issue. – Rakesh Jesadiya Jul 4 '17 at 13:29
  • 1
    The point of the stackexchange.com is to share information and solutions to the problem. @iamkdev could you please share your code. – knospe Jan 30 '18 at 9:31
  • Hello @iamkdev, it will send admin too? – chirag May 30 '18 at 12:22
  • 2
    Adding a comment and not sharing the code how can this be the accepted answer? Atleast show some code to prove it – MadzQuestioning Mar 24 '19 at 19:00
  • Can you share the code..?? – SUBIN CHANDRAN Mar 20 at 12:26

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.