I have custom functionality where orders can be canceled. I was wondering if M2 has some settings that sends automatic email to customer whose order was canceled? Or I need to implement it myself? If I need to implement it myself, I should follow this How to send mail programmaticlly in magento2?? Thank you.

1 Answer 1


I guess magento is not sending email default when order canceled while we can make a custom module for it.We will require a event and that will fire when order is canceled.

I have check magento2 event list and found event "order_cancel_after" that can we use in our observer.

You will need to create a module and use observer.

create events.xml file at path companyname/modulename/etc/adminhtml/events.xml

add the below code,

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="order_cancel_after">
        <observer name="order_cancel" instance="companyname\modulename\Observer\ordercancel" />

Create observer file ordercancel.php at path companyname\modulename\Observer and insert the below code,


class ordercancel implements ObserverInterface

   public function __construct(
    ) {


    public function execute(\Magento\Framework\Event\Observer $observer)
       //implement here for sending mail

There is also some discussion about that topic,you can review it


This will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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