I am trying to build a custom module that will trigger off a text message when Magento receives shipping information on orders.

I know I can trigger off email, sms etc when an order is placed by listening for the event 'order' referring to this line

$this->_eventManager->dispatch('sales_order_place_after', ['order' => $this]);

In this php file


So my question is where can I find the event that triggers the default email that gets send when a shipment is generated in Magento2?

2 Answers 2



<?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="sales_order_shipment_save_after">
        <observer name="myname" instance="Vendor\MyModule\Observer\ProcessShipment" />

then use it like this

namespace Vendor\MyModule\Observer;

use Magento\Framework\Event\ObserverInterface;

class ProcessShipment implements ObserverInterface
     * @param \Magento\Framework\Event\Observer $observer
     * @return $this
    public function execute(\Magento\Framework\Event\Observer $observer)
        $shipment = $observer->getEvent()->getShipment();
        $order = $shipment->getOrder();
        // your code here

Open vendor/magento/module-shipping/Controller/Adminhtml/Order/Shipment/Save.php and check the following line:

if (!empty($data['send_email']) && $this->salesData->canSendNewShipmentEmail()) {

Following class is responsible: vendor/magento/module-sales/Model/Order/Email/Sender/ShipmentSender.php

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.